(I'm thinking of appying this patch to libvirt in the F15 and F16 branches, as well as Rawhide. The intent is to prepare everyone for qemu's removal of support for the "fedora-13" machine type, which will happen in F17 (already done in Rawhide)).
This addresses https://bugzilla.redhat.com/show_bug.cgi?id=754772 . It should only be applied to Fedora builds of libvirt (it seems appropriate to apply it to all versions currently in support). Background: During the lifetime of Fedora 13, some features were backported into the F13 build of qemu-kvm from upstream. These features were part of the functionality of machine type "pc-0.13" in upstream qemu-kvm, so a special "fedora-13" machine type was created for the F13 qemu-kvm. Since this fedora-13 became the new "canonical machine type", all new domains created with F13 libvirt tools by default contained that machine type in their configuration file. With the release of Fedora 16, qemu-kvm initially removed support for this machine type, which caused failure of many guest configurations to start. qemu-kvm subsequently re-added the patch to support fedora-13, but with the promise that they could remove it with the release of Fedora 17. (see https://bugzilla.redhat.com/show_bug.cgi?id=748218 ). Solution: In order to create a repeat of the recent problems, prior to F17 existing guest configurations need to be updated to change fedora-13 to pc-0.13 (which has been determined to be equivalent for all practical purposes). That's what this patch does: Each time libvirtd is started, it calls virDomainLoadAllConfigs() which calls virDomainLoadConfig(); this function has been modified to check for os.machine == "fedora-13", and change it to "pc-0.13" then write the updated config back to disk. Also, any other time a domain definition is parsed, the parsed version in memory is changed to turn "fedora-13" into "pc-0.13". This handles domains that had been saved to disk prior to the upgrade, and are subsequently restarted. Finally, whenever a domain definition is formatted into a string, any occurence of fedora-13 is replaced with pc-0.13. This should deal with those cases where a domain was running at the time of upgrade, and is later saved/snapshotted. I had considered doing this with some sed commands in the specfile, but that wouldn't do anything to help the xml saved in image files. (Also, one of the xml tests was using the machine type "fedora-13", and since that machine type is treated specially by the rest of this patch, it was failing. It has been changed to use machine type pc-0.13 instead.) --- src/conf/domain_conf.c | 52 ++++++++++++++++++- .../qemuxml2argv-encrypted-disk.args | 2 +- .../qemuxml2argv-encrypted-disk.xml | 2 +- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 75e51a0..bf3dd88 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8061,7 +8061,25 @@ virDomainDefPtr virDomainDefParseString(virCapsPtr caps, unsigned int expectedVirtTypes, unsigned int flags) { - return virDomainDefParse(xmlStr, NULL, caps, expectedVirtTypes, flags); + virDomainDefPtr def + = virDomainDefParse(xmlStr, NULL, caps, expectedVirtTypes, flags); + + /* Fedora-specific HACK - treat fedora-13 and pc-0.13 as equivalent. + * This handles the case of domains that had been saved to an image file + * prior to upgrade (save or snapshot), then restarted/reverted. + */ + if (def && STREQ_NULLABLE(def->os.machine, "fedora-13")) { + VIR_FREE(def->os.machine); + if (!(def->os.machine = strdup("pc-0.13"))) { + virReportOOMError(); + virDomainDefFree(def); + def = NULL; + } else { + VIR_WARN("Replacing deprecated 'fedora-13' machine type " + "with equivalent 'pc-0.13' in domain %s xml", def->name); + } + } + return def; } virDomainDefPtr virDomainDefParseFile(virCapsPtr caps, @@ -11343,8 +11361,20 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAddLit(buf, " <type"); if (def->os.arch) virBufferAsprintf(buf, " arch='%s'", def->os.arch); - if (def->os.machine) - virBufferAsprintf(buf, " machine='%s'", def->os.machine); + if (def->os.machine) { + /* Fedora-specific HACK - replace "fedora-13" with "pc-0.13". + * This will catch XML being written to save/migration images + * of domains that were running when libvirtd was restarted at + * the time of upgrade. + */ + if (STREQ_NULLABLE(def->os.machine, "fedora-13")) { + virBufferAddLit(buf, " machine='pc-0.13'"); + VIR_WARN("substituting machine type 'fedora-13' with 'pc-0.13' " + "in domain %s", def->name); + } else { + virBufferAsprintf(buf, " machine='%s'", def->os.machine); + } + } /* * HACK: For xen driver we previously used bogus 'linux' as the * os type for paravirt, whereas capabilities declare it to @@ -11779,6 +11809,22 @@ static virDomainObjPtr virDomainLoadConfig(virCapsPtr caps, VIR_DOMAIN_XML_INACTIVE))) goto error; + /* Fedora-specific HACK - replace "fedora-13" with "pc-0.13". + * This updates all config files at the first restart of libvirt + * after upgrade. + */ + if (STREQ_NULLABLE(def->os.machine, "fedora-13")) { + VIR_FREE(def->os.machine); + if (!(def->os.machine = strdup("pc-0.13"))) { + virReportOOMError(); + goto error; + } + VIR_WARN("Replacing deprecated 'fedora-13' machine type " + "with equivalent 'pc-0.13' in domain %s configuration file", name); + if (virDomainSaveConfig(configDir, def) < 0) + goto error; + } + if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) goto error; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.args b/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.args index 1da0073..c6634fd 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.args @@ -1,5 +1,5 @@ LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin HOME=/root USER=root LOGNAME=root \ -/usr/bin/qemu -S -M fedora-13 -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name \ +/usr/bin/qemu -S -M pc-0.13 -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name \ encryptdisk -uuid 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 -nographic -nodefconfig \ -nodefaults -chardev socket,id=monitor,\ path=//var/lib/libvirt/qemu/encryptdisk.monitor,server,nowait -mon \ diff --git a/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.xml b/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.xml index f5e5d74..fdcf624 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.xml +++ b/tests/qemuxml2argvdata/qemuxml2argv-encrypted-disk.xml @@ -5,7 +5,7 @@ <currentMemory>524288</currentMemory> <vcpu>1</vcpu> <os> - <type arch='i686' machine='fedora-13'>hvm</type> + <type arch='i686' machine='pc-0.13'>hvm</type> <boot dev='hd'/> </os> <clock offset='utc'/> -- 1.7.7.3 _______________________________________________ virt mailing list [email protected] https://admin.fedoraproject.org/mailman/listinfo/virt
