Commit e8b2a1c648c095b5d431c50668709b714843ebb1
Committed by
Anthony Liguori
1 parent
21d58b57
Add a pc-0-10 machine type for compatibility with 0.10.x
Add a pc-0-10 machine type to allow a pc machine to be created with virtio block and console devices compatibility with qemu-0.10.x. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
1 changed file
with
53 additions
and
6 deletions
hw/pc.c
... | ... | @@ -1081,12 +1081,20 @@ static CPUState *pc_new_cpu(const char *cpu_model) |
1081 | 1081 | return env; |
1082 | 1082 | } |
1083 | 1083 | |
1084 | +enum { | |
1085 | + COMPAT_DEFAULT = 0, | |
1086 | + COMPAT_0_10, /* compatible with qemu 0.10.x */ | |
1087 | +}; | |
1088 | + | |
1084 | 1089 | /* PC hardware initialisation */ |
1085 | 1090 | static void pc_init1(ram_addr_t ram_size, |
1086 | 1091 | const char *boot_device, |
1087 | - const char *kernel_filename, const char *kernel_cmdline, | |
1092 | + const char *kernel_filename, | |
1093 | + const char *kernel_cmdline, | |
1088 | 1094 | const char *initrd_filename, |
1089 | - int pci_enabled, const char *cpu_model) | |
1095 | + const char *cpu_model, | |
1096 | + int pci_enabled, | |
1097 | + int compat_level) | |
1090 | 1098 | { |
1091 | 1099 | char *filename; |
1092 | 1100 | int ret, linux_boot, i; |
... | ... | @@ -1104,6 +1112,7 @@ static void pc_init1(ram_addr_t ram_size, |
1104 | 1112 | BlockDriverState *fd[MAX_FD]; |
1105 | 1113 | int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled; |
1106 | 1114 | void *fw_cfg; |
1115 | + const char *virtio_blk_name, *virtio_console_name; | |
1107 | 1116 | |
1108 | 1117 | if (ram_size >= 0xe0000000 ) { |
1109 | 1118 | above_4g_mem_size = ram_size - 0xe0000000; |
... | ... | @@ -1394,13 +1403,26 @@ static void pc_init1(ram_addr_t ram_size, |
1394 | 1403 | } |
1395 | 1404 | } |
1396 | 1405 | |
1406 | + switch (compat_level) { | |
1407 | + case COMPAT_DEFAULT: | |
1408 | + default: | |
1409 | + virtio_blk_name = "virtio-blk-pci"; | |
1410 | + virtio_console_name = "virtio-console-pci"; | |
1411 | + break; | |
1412 | + | |
1413 | + case COMPAT_0_10: | |
1414 | + virtio_blk_name = "virtio-blk-pci-0-10"; | |
1415 | + virtio_console_name = "virtio-console-pci-0-10"; | |
1416 | + break; | |
1417 | + } | |
1418 | + | |
1397 | 1419 | /* Add virtio block devices */ |
1398 | 1420 | if (pci_enabled) { |
1399 | 1421 | int index; |
1400 | 1422 | int unit_id = 0; |
1401 | 1423 | |
1402 | 1424 | while ((index = drive_get_index(IF_VIRTIO, 0, unit_id)) != -1) { |
1403 | - pci_dev = pci_create("virtio-blk-pci", | |
1425 | + pci_dev = pci_create(virtio_blk_name, | |
1404 | 1426 | drives_table[index].devaddr); |
1405 | 1427 | qdev_init(&pci_dev->qdev); |
1406 | 1428 | unit_id++; |
... | ... | @@ -1417,7 +1439,7 @@ static void pc_init1(ram_addr_t ram_size, |
1417 | 1439 | if (pci_enabled) { |
1418 | 1440 | for(i = 0; i < MAX_VIRTIO_CONSOLES; i++) { |
1419 | 1441 | if (virtcon_hds[i]) { |
1420 | - pci_create_simple(pci_bus, -1, "virtio-console-pci"); | |
1442 | + pci_create_simple(pci_bus, -1, virtio_console_name); | |
1421 | 1443 | } |
1422 | 1444 | } |
1423 | 1445 | } |
... | ... | @@ -1432,7 +1454,8 @@ static void pc_init_pci(ram_addr_t ram_size, |
1432 | 1454 | { |
1433 | 1455 | pc_init1(ram_size, boot_device, |
1434 | 1456 | kernel_filename, kernel_cmdline, |
1435 | - initrd_filename, 1, cpu_model); | |
1457 | + initrd_filename, cpu_model, | |
1458 | + 1, COMPAT_DEFAULT); | |
1436 | 1459 | } |
1437 | 1460 | |
1438 | 1461 | static void pc_init_isa(ram_addr_t ram_size, |
... | ... | @@ -1444,7 +1467,21 @@ static void pc_init_isa(ram_addr_t ram_size, |
1444 | 1467 | { |
1445 | 1468 | pc_init1(ram_size, boot_device, |
1446 | 1469 | kernel_filename, kernel_cmdline, |
1447 | - initrd_filename, 0, cpu_model); | |
1470 | + initrd_filename, cpu_model, | |
1471 | + 0, COMPAT_DEFAULT); | |
1472 | +} | |
1473 | + | |
1474 | +static void pc_init_pci_0_10(ram_addr_t ram_size, | |
1475 | + const char *boot_device, | |
1476 | + const char *kernel_filename, | |
1477 | + const char *kernel_cmdline, | |
1478 | + const char *initrd_filename, | |
1479 | + const char *cpu_model) | |
1480 | +{ | |
1481 | + pc_init1(ram_size, boot_device, | |
1482 | + kernel_filename, kernel_cmdline, | |
1483 | + initrd_filename, cpu_model, | |
1484 | + 1, COMPAT_0_10); | |
1448 | 1485 | } |
1449 | 1486 | |
1450 | 1487 | /* set CMOS shutdown status register (index 0xF) as S3_resume(0xFE) |
... | ... | @@ -1470,10 +1507,20 @@ static QEMUMachine isapc_machine = { |
1470 | 1507 | .max_cpus = 1, |
1471 | 1508 | }; |
1472 | 1509 | |
1510 | +static QEMUMachine pc_0_10_machine = { | |
1511 | + .name = "pc-0-10", | |
1512 | + .desc = "Standard PC compatible with qemu 0.10.x", | |
1513 | + .init = pc_init_pci_0_10, | |
1514 | + .max_cpus = 255, | |
1515 | +}; | |
1516 | + | |
1473 | 1517 | static void pc_machine_init(void) |
1474 | 1518 | { |
1475 | 1519 | qemu_register_machine(&pc_machine); |
1476 | 1520 | qemu_register_machine(&isapc_machine); |
1521 | + | |
1522 | + /* For compatibility with 0.10.x */ | |
1523 | + qemu_register_machine(&pc_0_10_machine); | |
1477 | 1524 | } |
1478 | 1525 | |
1479 | 1526 | machine_init(pc_machine_init); | ... | ... |