From b5414a9ca3adba64012c959883e20900fc04c93a05ed729791248ca9dc96d5b8 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Tue, 6 May 2014 17:46:39 +0000 Subject: [PATCH 1/3] - CVE-2014-0179: Don't expand entities when parsing XML d6b27d3e-CVE-2014-0179.patch bnc#873705 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=368 --- d6b27d3e-CVE-2014-0179.patch | 34 ++++++++++++++++++++++++++++++++++ libvirt.changes | 7 +++++++ libvirt.spec | 2 ++ 3 files changed, 43 insertions(+) create mode 100644 d6b27d3e-CVE-2014-0179.patch diff --git a/d6b27d3e-CVE-2014-0179.patch b/d6b27d3e-CVE-2014-0179.patch new file mode 100644 index 0000000..cb33491 --- /dev/null +++ b/d6b27d3e-CVE-2014-0179.patch @@ -0,0 +1,34 @@ +commit d6b27d3e4c40946efa79e91d134616b41b1666c4 +Author: Daniel P. Berrange +Date: Tue Apr 15 11:20:29 2014 +0100 + + LSN-2014-0003: Don't expand entities when parsing XML + + If the XML_PARSE_NOENT flag is passed to libxml2, then any + entities in the input document will be fully expanded. This + allows the user to read arbitrary files on the host machine + by creating an entity pointing to a local file. Removing + the XML_PARSE_NOENT flag means that any entities are left + unchanged by the parser, or expanded to "" by the XPath + APIs. + + Signed-off-by: Daniel P. Berrange + +Index: libvirt-1.2.3/src/util/virxml.c +=================================================================== +--- libvirt-1.2.3.orig/src/util/virxml.c ++++ libvirt-1.2.3/src/util/virxml.c +@@ -746,11 +746,11 @@ virXMLParseHelper(int domcode, + + if (filename) { + xml = xmlCtxtReadFile(pctxt, filename, NULL, +- XML_PARSE_NOENT | XML_PARSE_NONET | ++ XML_PARSE_NONET | + XML_PARSE_NOWARNING); + } else { + xml = xmlCtxtReadDoc(pctxt, BAD_CAST xmlStr, url, NULL, +- XML_PARSE_NOENT | XML_PARSE_NONET | ++ XML_PARSE_NONET | + XML_PARSE_NOWARNING); + } + if (!xml) diff --git a/libvirt.changes b/libvirt.changes index 33ecba3..9193c84 100644 --- a/libvirt.changes +++ b/libvirt.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon May 5 16:47:43 MDT 2014 - jfehlig@suse.com + +- CVE-2014-0179: Don't expand entities when parsing XML + d6b27d3e-CVE-2014-0179.patch + bnc#873705 + ------------------------------------------------------------------- Tue Apr 8 09:44:50 MDT 2014 - jfehlig@suse.com diff --git a/libvirt.spec b/libvirt.spec index 7ca178b..7dc2e40 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -430,6 +430,7 @@ Source99: baselibs.conf # Upstream patches Patch0: 0e0c1a74-domid-fix.patch Patch1: 7a1452f5-libxl-empty-cdrom.patch +Patch2: d6b27d3e-CVE-2014-0179.patch # Need to go upstream Patch100: xen-name-for-devid.patch Patch101: ia64-clone.patch @@ -948,6 +949,7 @@ namespaces. %setup -q %patch0 -p1 %patch1 -p1 +%patch2 -p1 %patch100 -p1 %patch101 -p1 %patch102 -p1 From 553e9bd0595e924019e0e65a0d437960b19dfbe1083ab62354ce26f4b374cfea Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Tue, 6 May 2014 18:02:27 +0000 Subject: [PATCH 2/3] - Update to libvirt 1.2.4 - Primarily a bug-fix release. See http://libvirt.org/news.html for a detailed list of bug fixes and improvements - Drop upstream patches: 0e0c1a74-domid-fix.patch, 7a1452f5-libxl-empty-cdrom.patch - libxl: Support ACPI shutdown event b98bf811-add-paravirt-shutdown-flag.patch, c4fe29f8-use-shutdown-flag.patch, da744120-use-reboot-flag.patch bnc#872777 - libx: Support migration libxl-migration-support.patch bnc#875193 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=369 --- b98bf811-add-paravirt-shutdown-flag.patch | 106 ++ c4fe29f8-use-shutdown-flag.patch | 68 ++ d6b27d3e-CVE-2014-0179.patch | 6 +- da744120-use-reboot-flag.patch | 44 + disable-virCgroupGetPercpuStats-test.patch | 8 +- fix-pci-attach-xen-driver.patch | 6 +- ia64-clone.patch | 6 +- install-apparmor-profiles.patch | 22 +- libvirt-1.2.3.tar.bz2 | 3 - libvirt-1.2.4.tar.bz2 | 3 + libvirt-guests-init-script.patch | 34 +- libvirt-suse-netcontrol.patch | 46 +- libvirt.changes | 16 + libvirt.spec | 23 +- libvirtd-defaults.patch | 18 +- libvirtd-init-script.patch | 6 +- libxl-migration-support.patch | 1028 ++++++++++++++++++++ support-managed-pci-xen-driver.patch | 12 +- suse-qemu-conf.patch | 6 +- systemd-service-xen.patch | 6 +- virtlockd-init-script.patch | 12 +- xen-name-for-devid.patch | 6 +- xen-pv-cdrom.patch | 6 +- 23 files changed, 1378 insertions(+), 113 deletions(-) create mode 100644 b98bf811-add-paravirt-shutdown-flag.patch create mode 100644 c4fe29f8-use-shutdown-flag.patch create mode 100644 da744120-use-reboot-flag.patch delete mode 100644 libvirt-1.2.3.tar.bz2 create mode 100644 libvirt-1.2.4.tar.bz2 create mode 100644 libxl-migration-support.patch diff --git a/b98bf811-add-paravirt-shutdown-flag.patch b/b98bf811-add-paravirt-shutdown-flag.patch new file mode 100644 index 0000000..97a16a0 --- /dev/null +++ b/b98bf811-add-paravirt-shutdown-flag.patch @@ -0,0 +1,106 @@ +commit b98bf81151446b34dde59217dec19f93981c8047 +Author: Jim Fehlig +Date: Thu May 1 11:42:54 2014 -0600 + + Introduce a new flag for controlling shutdown/reboot + + Add a new flag to virDomain{Reboot,Shutdown}FlagValues to allow + shutting down and rebooting a domain via the Xen paravirt control + interface. + +Index: libvirt-1.2.4/include/libvirt/libvirt.h.in +=================================================================== +--- libvirt-1.2.4.orig/include/libvirt/libvirt.h.in ++++ libvirt-1.2.4/include/libvirt/libvirt.h.in +@@ -1652,6 +1652,7 @@ typedef enum { + VIR_DOMAIN_SHUTDOWN_GUEST_AGENT = (1 << 1), /* Use guest agent */ + VIR_DOMAIN_SHUTDOWN_INITCTL = (1 << 2), /* Use initctl */ + VIR_DOMAIN_SHUTDOWN_SIGNAL = (1 << 3), /* Send a signal */ ++ VIR_DOMAIN_SHUTDOWN_PARAVIRT = (1 << 4), /* Use paravirt guest control */ + } virDomainShutdownFlagValues; + + int virDomainShutdown (virDomainPtr domain); +@@ -1664,6 +1665,7 @@ typedef enum { + VIR_DOMAIN_REBOOT_GUEST_AGENT = (1 << 1), /* Use guest agent */ + VIR_DOMAIN_REBOOT_INITCTL = (1 << 2), /* Use initctl */ + VIR_DOMAIN_REBOOT_SIGNAL = (1 << 3), /* Send a signal */ ++ VIR_DOMAIN_REBOOT_PARAVIRT = (1 << 4), /* Use paravirt guest control */ + } virDomainRebootFlagValues; + + int virDomainReboot (virDomainPtr domain, +Index: libvirt-1.2.4/tools/virsh-domain.c +=================================================================== +--- libvirt-1.2.4.orig/tools/virsh-domain.c ++++ libvirt-1.2.4/tools/virsh-domain.c +@@ -4837,7 +4837,7 @@ static const vshCmdOptDef opts_shutdown[ + }, + {.name = "mode", + .type = VSH_OT_STRING, +- .help = N_("shutdown mode: acpi|agent|initctl|signal") ++ .help = N_("shutdown mode: acpi|agent|initctl|signal|paravirt") + }, + {.name = NULL} + }; +@@ -4872,9 +4872,12 @@ cmdShutdown(vshControl *ctl, const vshCm + flags |= VIR_DOMAIN_SHUTDOWN_INITCTL; + } else if (STREQ(mode, "signal")) { + flags |= VIR_DOMAIN_SHUTDOWN_SIGNAL; ++ } else if (STREQ(mode, "paravirt")) { ++ flags |= VIR_DOMAIN_SHUTDOWN_PARAVIRT; + } else { + vshError(ctl, _("Unknown mode %s value, expecting " +- "'acpi', 'agent', 'initctl' or 'signal'"), mode); ++ "'acpi', 'agent', 'initctl', 'signal', " ++ "or 'paravirt'"), mode); + goto cleanup; + } + tmp++; +@@ -4923,7 +4926,7 @@ static const vshCmdOptDef opts_reboot[] + }, + {.name = "mode", + .type = VSH_OT_STRING, +- .help = N_("shutdown mode: acpi|agent|initctl|signal") ++ .help = N_("shutdown mode: acpi|agent|initctl|signal|paravirt") + }, + {.name = NULL} + }; +@@ -4957,9 +4960,12 @@ cmdReboot(vshControl *ctl, const vshCmd + flags |= VIR_DOMAIN_REBOOT_INITCTL; + } else if (STREQ(mode, "signal")) { + flags |= VIR_DOMAIN_REBOOT_SIGNAL; ++ } else if (STREQ(mode, "paravirt")) { ++ flags |= VIR_DOMAIN_REBOOT_PARAVIRT; + } else { + vshError(ctl, _("Unknown mode %s value, expecting " +- "'acpi', 'agent', 'initctl' or 'signal'"), mode); ++ "'acpi', 'agent', 'initctl', 'signal' " ++ "or 'paravirt'"), mode); + goto cleanup; + } + tmp++; +Index: libvirt-1.2.4/tools/virsh.pod +=================================================================== +--- libvirt-1.2.4.orig/tools/virsh.pod ++++ libvirt-1.2.4/tools/virsh.pod +@@ -1302,8 +1302,8 @@ I parameter in the domain's X + By default the hypervisor will try to pick a suitable shutdown + method. To specify an alternative method, the I<--mode> parameter + can specify a comma separated list which includes C, C, +-C and C. The order in which drivers will try each +-mode is undefined, and not related to the order specified to virsh. ++C, C and C. The order in which drivers will ++try each mode is undefined, and not related to the order specified to virsh. + For strict control over ordering, use a single mode at a time and + repeat the command. + +@@ -1781,8 +1781,8 @@ snapshot metadata with B parameter + can specify a comma separated list which includes C, C, +-C and C. The order in which drivers will try each +-mode is undefined, and not related to the order specified to virsh. ++C, C and C. The order in which drivers will ++try each mode is undefined, and not related to the order specified to virsh. + For strict control over ordering, use a single mode at a time and + repeat the command. + diff --git a/c4fe29f8-use-shutdown-flag.patch b/c4fe29f8-use-shutdown-flag.patch new file mode 100644 index 0000000..d8ee978 --- /dev/null +++ b/c4fe29f8-use-shutdown-flag.patch @@ -0,0 +1,68 @@ +commit c4fe29f88c4c1d5f571941e95c26246c8c84ce45 +Author: Jim Fehlig +Date: Thu May 1 12:11:51 2014 -0600 + + libxl: support PARAVIRT and ACPI shutdown flags + + Add support for VIR_DOMAIN_SHUTDOWN_PARAVIRT and + VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN flags in + libxlDomainShutdownFlags(). + +Index: libvirt-1.2.4/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-1.2.4.orig/src/libxl/libxl_driver.c ++++ libvirt-1.2.4/src/libxl/libxl_driver.c +@@ -873,7 +873,11 @@ libxlDomainShutdownFlags(virDomainPtr do + int ret = -1; + libxlDomainObjPrivatePtr priv; + +- virCheckFlags(0, -1); ++ virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN | ++ VIR_DOMAIN_SHUTDOWN_PARAVIRT, -1); ++ if (flags == 0) ++ flags = VIR_DOMAIN_SHUTDOWN_PARAVIRT | ++ VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN; + + if (!(vm = libxlDomObjFromDomain(dom))) + goto cleanup; +@@ -888,18 +892,33 @@ libxlDomainShutdownFlags(virDomainPtr do + } + + priv = vm->privateData; +- if (libxl_domain_shutdown(priv->ctx, vm->def->id) != 0) { ++ if (flags & VIR_DOMAIN_SHUTDOWN_PARAVIRT) { ++ ret = libxl_domain_shutdown(priv->ctx, vm->def->id); ++ if (ret == 0) ++ goto cleanup; ++ ++ if (ret != ERROR_NOPARAVIRT) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, ++ _("Failed to shutdown domain '%d' with libxenlight"), ++ vm->def->id); ++ ret = -1; ++ goto cleanup; ++ } ++ ret = -1; ++ } ++ ++ if (flags & VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN) { ++ ret = libxl_send_trigger(priv->ctx, vm->def->id, ++ LIBXL_TRIGGER_POWER, 0); ++ if (ret == 0) ++ goto cleanup; ++ + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to shutdown domain '%d' with libxenlight"), + vm->def->id); +- goto cleanup; ++ ret = -1; + } + +- /* vm is marked shutoff (or removed from domains list if not persistent) +- * in shutdown event handler. +- */ +- ret = 0; +- + cleanup: + if (vm) + virObjectUnlock(vm); diff --git a/d6b27d3e-CVE-2014-0179.patch b/d6b27d3e-CVE-2014-0179.patch index cb33491..ef9e107 100644 --- a/d6b27d3e-CVE-2014-0179.patch +++ b/d6b27d3e-CVE-2014-0179.patch @@ -14,10 +14,10 @@ Date: Tue Apr 15 11:20:29 2014 +0100 Signed-off-by: Daniel P. Berrange -Index: libvirt-1.2.3/src/util/virxml.c +Index: libvirt-1.2.4/src/util/virxml.c =================================================================== ---- libvirt-1.2.3.orig/src/util/virxml.c -+++ libvirt-1.2.3/src/util/virxml.c +--- libvirt-1.2.4.orig/src/util/virxml.c ++++ libvirt-1.2.4/src/util/virxml.c @@ -746,11 +746,11 @@ virXMLParseHelper(int domcode, if (filename) { diff --git a/da744120-use-reboot-flag.patch b/da744120-use-reboot-flag.patch new file mode 100644 index 0000000..db3a67f --- /dev/null +++ b/da744120-use-reboot-flag.patch @@ -0,0 +1,44 @@ +commit da7441204635f4692c729af089ad455365f37b2f +Author: Jim Fehlig +Date: Thu May 1 15:00:47 2014 -0600 + + libxl: support PARAVIRT reboot flag + + Add support for the VIR_DOMAIN_REBOOT_PARAVIRT flag in + libxlDomainReboot(). + +Index: libvirt-1.2.4/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-1.2.4.orig/src/libxl/libxl_driver.c ++++ libvirt-1.2.4/src/libxl/libxl_driver.c +@@ -939,7 +939,9 @@ libxlDomainReboot(virDomainPtr dom, unsi + int ret = -1; + libxlDomainObjPrivatePtr priv; + +- virCheckFlags(0, -1); ++ virCheckFlags(VIR_DOMAIN_REBOOT_PARAVIRT, -1); ++ if (flags == 0) ++ flags = VIR_DOMAIN_REBOOT_PARAVIRT; + + if (!(vm = libxlDomObjFromDomain(dom))) + goto cleanup; +@@ -954,13 +956,16 @@ libxlDomainReboot(virDomainPtr dom, unsi + } + + priv = vm->privateData; +- if (libxl_domain_reboot(priv->ctx, vm->def->id) != 0) { ++ if (flags & VIR_DOMAIN_REBOOT_PARAVIRT) { ++ ret = libxl_domain_reboot(priv->ctx, vm->def->id); ++ if (ret == 0) ++ goto cleanup; ++ + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to reboot domain '%d' with libxenlight"), + vm->def->id); +- goto cleanup; ++ ret = -1; + } +- ret = 0; + + cleanup: + if (vm) diff --git a/disable-virCgroupGetPercpuStats-test.patch b/disable-virCgroupGetPercpuStats-test.patch index 166804a..d1fb56e 100644 --- a/disable-virCgroupGetPercpuStats-test.patch +++ b/disable-virCgroupGetPercpuStats-test.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/tests/vircgrouptest.c +Index: libvirt-1.2.4/tests/vircgrouptest.c =================================================================== ---- libvirt-1.2.3.orig/tests/vircgrouptest.c -+++ libvirt-1.2.3/tests/vircgrouptest.c +--- libvirt-1.2.4.orig/tests/vircgrouptest.c ++++ libvirt-1.2.4/tests/vircgrouptest.c @@ -33,7 +33,6 @@ # include "virlog.h" # include "virfile.h" @@ -41,7 +41,7 @@ Index: libvirt-1.2.3/tests/vircgrouptest.c - - if ((rv = virCgroupGetPercpuStats(cgroup, - params, -- 2, 0, 1)) < 0) { +- 2, 0, 1, 0)) < 0) { - fprintf(stderr, "Failed call to virCgroupGetPercpuStats for /virtualmachines cgroup: %d\n", -rv); - goto cleanup; - } diff --git a/fix-pci-attach-xen-driver.patch b/fix-pci-attach-xen-driver.patch index 1ec062e..b849e3b 100644 --- a/fix-pci-attach-xen-driver.patch +++ b/fix-pci-attach-xen-driver.patch @@ -8,10 +8,10 @@ uses the 'device_configure' RPC. This patch changes the xend driver to always call 'device_configure' for PCI devices to be consistent with the usage in the xen tools. -Index: libvirt-1.2.3/src/xen/xend_internal.c +Index: libvirt-1.2.4/src/xen/xend_internal.c =================================================================== ---- libvirt-1.2.3.orig/src/xen/xend_internal.c -+++ libvirt-1.2.3/src/xen/xend_internal.c +--- libvirt-1.2.4.orig/src/xen/xend_internal.c ++++ libvirt-1.2.4/src/xen/xend_internal.c @@ -2219,6 +2219,7 @@ xenDaemonAttachDeviceFlags(virConnectPtr virBuffer buf = VIR_BUFFER_INITIALIZER; char class[8], ref[80]; diff --git a/ia64-clone.patch b/ia64-clone.patch index aaaaeba..f2c0986 100644 --- a/ia64-clone.patch +++ b/ia64-clone.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/src/lxc/lxc_container.c +Index: libvirt-1.2.4/src/lxc/lxc_container.c =================================================================== ---- libvirt-1.2.3.orig/src/lxc/lxc_container.c -+++ libvirt-1.2.3/src/lxc/lxc_container.c +--- libvirt-1.2.4.orig/src/lxc/lxc_container.c ++++ libvirt-1.2.4/src/lxc/lxc_container.c @@ -164,12 +164,19 @@ int lxcContainerHasReboot(void) VIR_FREE(buf); cmd = v ? LINUX_REBOOT_CMD_CAD_ON : LINUX_REBOOT_CMD_CAD_OFF; diff --git a/install-apparmor-profiles.patch b/install-apparmor-profiles.patch index a78fd31..40bc42e 100644 --- a/install-apparmor-profiles.patch +++ b/install-apparmor-profiles.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/examples/apparmor/Makefile.am +Index: libvirt-1.2.4/examples/apparmor/Makefile.am =================================================================== ---- libvirt-1.2.3.orig/examples/apparmor/Makefile.am -+++ libvirt-1.2.3/examples/apparmor/Makefile.am +--- libvirt-1.2.4.orig/examples/apparmor/Makefile.am ++++ libvirt-1.2.4/examples/apparmor/Makefile.am @@ -18,10 +18,22 @@ EXTRA_DIST= \ TEMPLATE \ libvirt-qemu \ @@ -27,10 +27,10 @@ Index: libvirt-1.2.3/examples/apparmor/Makefile.am apparmordir = $(sysconfdir)/apparmor.d/ apparmor_DATA = \ usr.lib.libvirt.virt-aa-helper \ -Index: libvirt-1.2.3/examples/apparmor/usr.lib.libvirt.virt-aa-helper.in +Index: libvirt-1.2.4/examples/apparmor/usr.lib.libvirt.virt-aa-helper.in =================================================================== --- /dev/null -+++ libvirt-1.2.3/examples/apparmor/usr.lib.libvirt.virt-aa-helper.in ++++ libvirt-1.2.4/examples/apparmor/usr.lib.libvirt.virt-aa-helper.in @@ -0,0 +1,48 @@ +# Last Modified: Mon Apr 5 15:10:27 2010 +#include @@ -80,10 +80,10 @@ Index: libvirt-1.2.3/examples/apparmor/usr.lib.libvirt.virt-aa-helper.in + /**.[iI][sS][oO] r, + /**/disk{,.*} r, +} -Index: libvirt-1.2.3/examples/apparmor/usr.sbin.libvirtd.in +Index: libvirt-1.2.4/examples/apparmor/usr.sbin.libvirtd.in =================================================================== --- /dev/null -+++ libvirt-1.2.3/examples/apparmor/usr.sbin.libvirtd.in ++++ libvirt-1.2.4/examples/apparmor/usr.sbin.libvirtd.in @@ -0,0 +1,67 @@ +# Last Modified: Mon Apr 5 15:03:58 2010 +#include @@ -152,9 +152,9 @@ Index: libvirt-1.2.3/examples/apparmor/usr.sbin.libvirtd.in + change_profile -> @{LIBVIRT}-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*-[0-9a-f]*, + +} -Index: libvirt-1.2.3/examples/apparmor/usr.lib.libvirt.virt-aa-helper +Index: libvirt-1.2.4/examples/apparmor/usr.lib.libvirt.virt-aa-helper =================================================================== ---- libvirt-1.2.3.orig/examples/apparmor/usr.lib.libvirt.virt-aa-helper +--- libvirt-1.2.4.orig/examples/apparmor/usr.lib.libvirt.virt-aa-helper +++ /dev/null @@ -1,48 +0,0 @@ -# Last Modified: Mon Apr 5 15:10:27 2010 @@ -205,9 +205,9 @@ Index: libvirt-1.2.3/examples/apparmor/usr.lib.libvirt.virt-aa-helper - /**.[iI][sS][oO] r, - /**/disk{,.*} r, -} -Index: libvirt-1.2.3/examples/apparmor/usr.sbin.libvirtd +Index: libvirt-1.2.4/examples/apparmor/usr.sbin.libvirtd =================================================================== ---- libvirt-1.2.3.orig/examples/apparmor/usr.sbin.libvirtd +--- libvirt-1.2.4.orig/examples/apparmor/usr.sbin.libvirtd +++ /dev/null @@ -1,63 +0,0 @@ -# Last Modified: Mon Apr 5 15:03:58 2010 diff --git a/libvirt-1.2.3.tar.bz2 b/libvirt-1.2.3.tar.bz2 deleted file mode 100644 index 9be8790..0000000 --- a/libvirt-1.2.3.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:030e1da22cbdd98427de96f087e0fbea5f15a2685799af161b4001f287175973 -size 20734026 diff --git a/libvirt-1.2.4.tar.bz2 b/libvirt-1.2.4.tar.bz2 new file mode 100644 index 0000000..3c6f201 --- /dev/null +++ b/libvirt-1.2.4.tar.bz2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:414b076d2de6c0e2f701b06ba2c6409caf017e46a40bd50bb359e4e012bbb3d1 +size 20655047 diff --git a/libvirt-guests-init-script.patch b/libvirt-guests-init-script.patch index 8f7c143..c6823c0 100644 --- a/libvirt-guests-init-script.patch +++ b/libvirt-guests-init-script.patch @@ -1,9 +1,9 @@ Adjust libvirt-guests init files to conform to SUSE standards -Index: libvirt-1.2.3/tools/libvirt-guests.init.in +Index: libvirt-1.2.4/tools/libvirt-guests.init.in =================================================================== ---- libvirt-1.2.3.orig/tools/libvirt-guests.init.in -+++ libvirt-1.2.3/tools/libvirt-guests.init.in +--- libvirt-1.2.4.orig/tools/libvirt-guests.init.in ++++ libvirt-1.2.4/tools/libvirt-guests.init.in @@ -3,15 +3,15 @@ # the following is the LSB init header # @@ -28,10 +28,10 @@ Index: libvirt-1.2.3/tools/libvirt-guests.init.in ### END INIT INFO # the following is chkconfig init header -Index: libvirt-1.2.3/tools/libvirt-guests.sh.in +Index: libvirt-1.2.4/tools/libvirt-guests.sh.in =================================================================== ---- libvirt-1.2.3.orig/tools/libvirt-guests.sh.in -+++ libvirt-1.2.3/tools/libvirt-guests.sh.in +--- libvirt-1.2.4.orig/tools/libvirt-guests.sh.in ++++ libvirt-1.2.4/tools/libvirt-guests.sh.in @@ -16,14 +16,13 @@ # License along with this library. If not, see # . @@ -100,7 +100,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in # test_connect URI # check if URI is reachable test_connect() -@@ -114,7 +134,7 @@ list_guests() { +@@ -116,7 +136,7 @@ list_guests() { list=$(run_virsh_c "$uri" list --uuid $persistent) if [ $? -ne 0 ]; then @@ -109,7 +109,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in return 1 fi -@@ -140,7 +160,7 @@ guest_is_on() { +@@ -142,7 +162,7 @@ guest_is_on() { guest_running=false id=$(run_virsh "$uri" domid "$uuid") if [ $? -ne 0 ]; then @@ -118,7 +118,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in return 1 fi -@@ -188,6 +208,12 @@ start() { +@@ -190,6 +210,12 @@ start() { test_connect "$uri" || continue @@ -131,7 +131,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in eval_gettext "Resuming guests on \$uri URI..."; echo for guest in $list; do name=$(guest_name "$uri" "$guest") -@@ -401,7 +427,7 @@ shutdown_guests_parallel() +@@ -403,7 +429,7 @@ shutdown_guests_parallel() timeout=$(($timeout - 1)) if [ $timeout -le 0 ]; then eval_gettext "Timeout expired while shutting down domains"; echo @@ -140,7 +140,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in return fi else -@@ -429,7 +455,7 @@ stop() { +@@ -431,7 +457,7 @@ stop() { if [ $SHUTDOWN_TIMEOUT -lt 0 ]; then gettext "SHUTDOWN_TIMEOUT must be equal or greater than 0" echo @@ -149,7 +149,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in return fi fi -@@ -477,14 +503,14 @@ stop() { +@@ -479,14 +505,14 @@ stop() { if [ $? -ne 0 ]; then eval_gettext "Failed to list persistent guests on \$uri" echo @@ -166,7 +166,7 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in set +f return fi -@@ -543,14 +569,13 @@ gueststatus() { +@@ -545,14 +571,13 @@ gueststatus() { rh_status() { if [ -f "$LISTFILE" ]; then gettext "stopped, with saved guests"; echo @@ -183,16 +183,16 @@ Index: libvirt-1.2.3/tools/libvirt-guests.sh.in fi fi } -@@ -595,4 +620,4 @@ case "$1" in +@@ -597,4 +622,4 @@ case "$1" in usage ;; esac -exit $RETVAL +rc_exit -Index: libvirt-1.2.3/tools/libvirt-guests.sysconf +Index: libvirt-1.2.4/tools/libvirt-guests.sysconf =================================================================== ---- libvirt-1.2.3.orig/tools/libvirt-guests.sysconf -+++ libvirt-1.2.3/tools/libvirt-guests.sysconf +--- libvirt-1.2.4.orig/tools/libvirt-guests.sysconf ++++ libvirt-1.2.4/tools/libvirt-guests.sysconf @@ -1,19 +1,29 @@ +## Path: System/Virtualization/libvirt-guests + diff --git a/libvirt-suse-netcontrol.patch b/libvirt-suse-netcontrol.patch index 3d5500a..b876e9f 100644 --- a/libvirt-suse-netcontrol.patch +++ b/libvirt-suse-netcontrol.patch @@ -1,8 +1,8 @@ -Index: libvirt-1.2.3/configure.ac +Index: libvirt-1.2.4/configure.ac =================================================================== ---- libvirt-1.2.3.orig/configure.ac -+++ libvirt-1.2.3/configure.ac -@@ -231,6 +231,7 @@ LIBVIRT_CHECK_FUSE +--- libvirt-1.2.4.orig/configure.ac ++++ libvirt-1.2.4/configure.ac +@@ -237,6 +237,7 @@ LIBVIRT_CHECK_FUSE LIBVIRT_CHECK_GLUSTER LIBVIRT_CHECK_HAL LIBVIRT_CHECK_NETCF @@ -10,7 +10,7 @@ Index: libvirt-1.2.3/configure.ac LIBVIRT_CHECK_NUMACTL LIBVIRT_CHECK_OPENWSMAN LIBVIRT_CHECK_PCIACCESS -@@ -2374,11 +2375,12 @@ if test "$with_libvirtd" = "no" ; then +@@ -2409,11 +2410,12 @@ if test "$with_libvirtd" = "no" ; then with_interface=no fi @@ -26,7 +26,7 @@ Index: libvirt-1.2.3/configure.ac esac if test "$with_interface" = "yes" ; then -@@ -2772,6 +2774,7 @@ LIBVIRT_RESULT_FUSE +@@ -2808,6 +2810,7 @@ LIBVIRT_RESULT_FUSE LIBVIRT_RESULT_GLUSTER LIBVIRT_RESULT_HAL LIBVIRT_RESULT_NETCF @@ -34,11 +34,11 @@ Index: libvirt-1.2.3/configure.ac LIBVIRT_RESULT_NUMACTL LIBVIRT_RESULT_OPENWSMAN LIBVIRT_RESULT_PCIACCESS -Index: libvirt-1.2.3/src/Makefile.am +Index: libvirt-1.2.4/src/Makefile.am =================================================================== ---- libvirt-1.2.3.orig/src/Makefile.am -+++ libvirt-1.2.3/src/Makefile.am -@@ -807,6 +807,10 @@ if WITH_NETCF +--- libvirt-1.2.4.orig/src/Makefile.am ++++ libvirt-1.2.4/src/Makefile.am +@@ -812,6 +812,10 @@ if WITH_NETCF INTERFACE_DRIVER_SOURCES += \ interface/interface_backend_netcf.c endif WITH_NETCF @@ -49,7 +49,7 @@ Index: libvirt-1.2.3/src/Makefile.am if WITH_UDEV INTERFACE_DRIVER_SOURCES += \ interface/interface_backend_udev.c -@@ -1396,10 +1400,15 @@ if WITH_NETCF +@@ -1402,10 +1406,15 @@ if WITH_NETCF libvirt_driver_interface_la_CFLAGS += $(NETCF_CFLAGS) libvirt_driver_interface_la_LIBADD += $(NETCF_LIBS) else ! WITH_NETCF @@ -65,11 +65,11 @@ Index: libvirt-1.2.3/src/Makefile.am endif ! WITH_NETCF if WITH_DRIVER_MODULES libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la -Index: libvirt-1.2.3/tools/virsh.c +Index: libvirt-1.2.4/tools/virsh.c =================================================================== ---- libvirt-1.2.3.orig/tools/virsh.c -+++ libvirt-1.2.3/tools/virsh.c -@@ -3251,6 +3251,8 @@ vshShowVersion(vshControl *ctl ATTRIBUTE +--- libvirt-1.2.4.orig/tools/virsh.c ++++ libvirt-1.2.4/tools/virsh.c +@@ -3252,6 +3252,8 @@ vshShowVersion(vshControl *ctl ATTRIBUTE vshPrint(ctl, " Interface"); # if defined(WITH_NETCF) vshPrint(ctl, " netcf"); @@ -78,10 +78,10 @@ Index: libvirt-1.2.3/tools/virsh.c # elif defined(WITH_UDEV) vshPrint(ctl, " udev"); # endif -Index: libvirt-1.2.3/src/interface/interface_backend_netcf.c +Index: libvirt-1.2.4/src/interface/interface_backend_netcf.c =================================================================== ---- libvirt-1.2.3.orig/src/interface/interface_backend_netcf.c -+++ libvirt-1.2.3/src/interface/interface_backend_netcf.c +--- libvirt-1.2.4.orig/src/interface/interface_backend_netcf.c ++++ libvirt-1.2.4/src/interface/interface_backend_netcf.c @@ -23,7 +23,12 @@ #include @@ -165,10 +165,10 @@ Index: libvirt-1.2.3/src/interface/interface_backend_netcf.c return 0; } -Index: libvirt-1.2.3/src/interface/interface_driver.c +Index: libvirt-1.2.4/src/interface/interface_driver.c =================================================================== ---- libvirt-1.2.3.orig/src/interface/interface_driver.c -+++ libvirt-1.2.3/src/interface/interface_driver.c +--- libvirt-1.2.4.orig/src/interface/interface_driver.c ++++ libvirt-1.2.4/src/interface/interface_driver.c @@ -30,8 +30,15 @@ interfaceRegister(void) if (netcfIfaceRegister() == 0) return 0; @@ -186,10 +186,10 @@ Index: libvirt-1.2.3/src/interface/interface_driver.c if (udevIfaceRegister() == 0) return 0; #endif /* WITH_UDEV */ -Index: libvirt-1.2.3/m4/virt-netcontrol.m4 +Index: libvirt-1.2.4/m4/virt-netcontrol.m4 =================================================================== --- /dev/null -+++ libvirt-1.2.3/m4/virt-netcontrol.m4 ++++ libvirt-1.2.4/m4/virt-netcontrol.m4 @@ -0,0 +1,35 @@ +dnl The libnetcontrol library +dnl diff --git a/libvirt.changes b/libvirt.changes index 9193c84..3150849 100644 --- a/libvirt.changes +++ b/libvirt.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Tue May 6 11:53:14 MDT 2014 - jfehlig@suse.com + +- Update to libvirt 1.2.4 + - Primarily a bug-fix release. See http://libvirt.org/news.html + for a detailed list of bug fixes and improvements + - Drop upstream patches: + 0e0c1a74-domid-fix.patch, 7a1452f5-libxl-empty-cdrom.patch +- libxl: Support ACPI shutdown event + b98bf811-add-paravirt-shutdown-flag.patch, + c4fe29f8-use-shutdown-flag.patch, da744120-use-reboot-flag.patch + bnc#872777 +- libx: Support migration + libxl-migration-support.patch + bnc#875193 + ------------------------------------------------------------------- Mon May 5 16:47:43 MDT 2014 - jfehlig@suse.com diff --git a/libvirt.spec b/libvirt.spec index 7dc2e40..617f242 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -235,7 +235,7 @@ Name: libvirt Url: http://libvirt.org/ -Version: 1.2.3 +Version: 1.2.4 Release: 0 Summary: Library providing a simple virtualization API License: LGPL-2.1+ @@ -428,14 +428,17 @@ Source1: libvirtd.init Source2: libvirtd-relocation-server.fw Source99: baselibs.conf # Upstream patches -Patch0: 0e0c1a74-domid-fix.patch -Patch1: 7a1452f5-libxl-empty-cdrom.patch -Patch2: d6b27d3e-CVE-2014-0179.patch +Patch0: b98bf811-add-paravirt-shutdown-flag.patch +Patch1: c4fe29f8-use-shutdown-flag.patch +Patch2: da744120-use-reboot-flag.patch +Patch3: d6b27d3e-CVE-2014-0179.patch # Need to go upstream Patch100: xen-name-for-devid.patch Patch101: ia64-clone.patch Patch102: xen-pv-cdrom.patch -Patch103: add-nocow-to-vol-xml.patch +#Patch103: add-nocow-to-vol-xml.patch +# pending review upstream patches +Patch150: libxl-migration-support.patch # Our patches Patch200: libvirtd-defaults.patch Patch201: libvirtd-init-script.patch @@ -950,10 +953,12 @@ namespaces. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 %patch100 -p1 %patch101 -p1 %patch102 -p1 -%patch103 -p1 +#%patch103 -p1 +%patch150 -p1 %patch200 -p1 %patch201 -p1 %patch202 -p1 @@ -1321,8 +1326,7 @@ rm -rf $RPM_BUILD_ROOT cd tests make # These tests don't current work in a mock build root -# qemuargv2xmltest: needs qemu user/group to be setup -for i in nodeinfotest seclabeltest qemuxml2argvtest +for i in nodeinfotest seclabeltest do rm -f $i printf 'int main(void) { return 0; }' > $i.c @@ -1750,8 +1754,7 @@ fi %{_datadir}/libvirt/schemas/nodedev.rng %{_datadir}/libvirt/schemas/nwfilter.rng %{_datadir}/libvirt/schemas/secret.rng -%{_datadir}/libvirt/schemas/storageencryption.rng -%{_datadir}/libvirt/schemas/storagefilefeatures.rng +%{_datadir}/libvirt/schemas/storagecommon.rng %{_datadir}/libvirt/schemas/storagepool.rng %{_datadir}/libvirt/schemas/storagevol.rng %{_datadir}/libvirt/cpu_map.xml diff --git a/libvirtd-defaults.patch b/libvirtd-defaults.patch index d32a04a..19222d8 100644 --- a/libvirtd-defaults.patch +++ b/libvirtd-defaults.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/daemon/libvirtd.conf +Index: libvirt-1.2.4/daemon/libvirtd.conf =================================================================== ---- libvirt-1.2.3.orig/daemon/libvirtd.conf -+++ libvirt-1.2.3/daemon/libvirtd.conf +--- libvirt-1.2.4.orig/daemon/libvirtd.conf ++++ libvirt-1.2.4/daemon/libvirtd.conf @@ -18,8 +18,8 @@ # It is necessary to setup a CA and issue server certificates before # using this capability. @@ -13,10 +13,10 @@ Index: libvirt-1.2.3/daemon/libvirtd.conf # Listen for unencrypted TCP connections on the public TCP/IP port. # NB, must pass the --listen flag to the libvirtd process for this to -Index: libvirt-1.2.3/daemon/libvirtd-config.c +Index: libvirt-1.2.4/daemon/libvirtd-config.c =================================================================== ---- libvirt-1.2.3.orig/daemon/libvirtd-config.c -+++ libvirt-1.2.3/daemon/libvirtd-config.c +--- libvirt-1.2.4.orig/daemon/libvirtd-config.c ++++ libvirt-1.2.4/daemon/libvirtd-config.c @@ -229,7 +229,7 @@ daemonConfigNew(bool privileged ATTRIBUT if (VIR_ALLOC(data) < 0) return NULL; @@ -26,10 +26,10 @@ Index: libvirt-1.2.3/daemon/libvirtd-config.c data->listen_tcp = 0; if (VIR_STRDUP(data->tls_port, LIBVIRTD_TLS_PORT) < 0 || -Index: libvirt-1.2.3/daemon/test_libvirtd.aug.in +Index: libvirt-1.2.4/daemon/test_libvirtd.aug.in =================================================================== ---- libvirt-1.2.3.orig/daemon/test_libvirtd.aug.in -+++ libvirt-1.2.3/daemon/test_libvirtd.aug.in +--- libvirt-1.2.4.orig/daemon/test_libvirtd.aug.in ++++ libvirt-1.2.4/daemon/test_libvirtd.aug.in @@ -2,7 +2,7 @@ module Test_libvirtd = ::CONFIG:: diff --git a/libvirtd-init-script.patch b/libvirtd-init-script.patch index 7c1f74f..b2e659d 100644 --- a/libvirtd-init-script.patch +++ b/libvirtd-init-script.patch @@ -1,9 +1,9 @@ Adjust libvirtd sysconfig file to conform to SUSE standards -Index: libvirt-1.2.3/daemon/libvirtd.sysconf +Index: libvirt-1.2.4/daemon/libvirtd.sysconf =================================================================== ---- libvirt-1.2.3.orig/daemon/libvirtd.sysconf -+++ libvirt-1.2.3/daemon/libvirtd.sysconf +--- libvirt-1.2.4.orig/daemon/libvirtd.sysconf ++++ libvirt-1.2.4/daemon/libvirtd.sysconf @@ -1,16 +1,25 @@ +## Path: System/Virtualization/libvirt + diff --git a/libxl-migration-support.patch b/libxl-migration-support.patch new file mode 100644 index 0000000..d2fe2e3 --- /dev/null +++ b/libxl-migration-support.patch @@ -0,0 +1,1028 @@ +From 766944b3f8ea6099b847c59f4cbe4d63802a461e Mon Sep 17 00:00:00 2001 +From: Jim Fehlig +Date: Tue, 25 Feb 2014 16:59:59 -0700 +Subject: [PATCH] libxl: add migration support + +This patch adds initial migration support to the libxl driver, +using the VIR_DRV_FEATURE_MIGRATION_PARAMS family of migration +functions. + +Signed-off-by: Jim Fehlig +--- + po/POTFILES.in | 1 + + src/Makefile.am | 3 +- + src/libxl/libxl_conf.h | 6 + + src/libxl/libxl_domain.h | 1 + + src/libxl/libxl_driver.c | 235 ++++++++++++++++++ + src/libxl/libxl_migration.c | 577 ++++++++++++++++++++++++++++++++++++++++++++ + src/libxl/libxl_migration.h | 78 ++++++ + 7 files changed, 900 insertions(+), 1 deletion(-) + +Index: libvirt-1.2.4/po/POTFILES.in +=================================================================== +--- libvirt-1.2.4.orig/po/POTFILES.in ++++ libvirt-1.2.4/po/POTFILES.in +@@ -73,6 +73,7 @@ src/lxc/lxc_process.c + src/libxl/libxl_domain.c + src/libxl/libxl_driver.c + src/libxl/libxl_conf.c ++src/libxl/libxl_migration.c + src/network/bridge_driver.c + src/network/bridge_driver_linux.c + src/node_device/node_device_driver.c +Index: libvirt-1.2.4/src/Makefile.am +=================================================================== +--- libvirt-1.2.4.orig/src/Makefile.am ++++ libvirt-1.2.4/src/Makefile.am +@@ -706,7 +706,8 @@ XENAPI_DRIVER_SOURCES = \ + LIBXL_DRIVER_SOURCES = \ + libxl/libxl_conf.c libxl/libxl_conf.h \ + libxl/libxl_domain.c libxl/libxl_domain.h \ +- libxl/libxl_driver.c libxl/libxl_driver.h ++ libxl/libxl_driver.c libxl/libxl_driver.h \ ++ libxl/libxl_migration.c libxl/libxl_migration.h + + UML_DRIVER_SOURCES = \ + uml/uml_conf.c uml/uml_conf.h \ +Index: libvirt-1.2.4/src/libxl/libxl_conf.h +=================================================================== +--- libvirt-1.2.4.orig/src/libxl/libxl_conf.h ++++ libvirt-1.2.4/src/libxl/libxl_conf.h +@@ -43,6 +43,9 @@ + # define LIBXL_VNC_PORT_MIN 5900 + # define LIBXL_VNC_PORT_MAX 65535 + ++# define LIBXL_MIGRATION_PORT_MIN 49152 ++# define LIBXL_MIGRATION_PORT_MAX 49216 ++ + # define LIBXL_CONFIG_DIR SYSCONFDIR "/libvirt/libxl" + # define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR "/autostart" + # define LIBXL_STATE_DIR LOCALSTATEDIR "/run/libvirt/libxl" +@@ -115,6 +118,9 @@ struct _libxlDriverPrivate { + /* Immutable pointer, self-locking APIs */ + virPortAllocatorPtr reservedVNCPorts; + ++ /* Immutable pointer, self-locking APIs */ ++ virPortAllocatorPtr migrationPorts; ++ + /* Immutable pointer, lockless APIs*/ + virSysinfoDefPtr hostsysinfo; + }; +Index: libvirt-1.2.4/src/libxl/libxl_domain.h +=================================================================== +--- libvirt-1.2.4.orig/src/libxl/libxl_domain.h ++++ libvirt-1.2.4/src/libxl/libxl_domain.h +@@ -69,6 +69,7 @@ struct _libxlDomainObjPrivate { + virChrdevsPtr devs; + libxl_evgen_domain_death *deathW; + libxlDriverPrivatePtr driver; ++ unsigned short migrationPort; + + struct libxlDomainJobObj job; + }; +Index: libvirt-1.2.4/src/libxl/libxl_driver.c +=================================================================== +--- libvirt-1.2.4.orig/src/libxl/libxl_driver.c ++++ libvirt-1.2.4/src/libxl/libxl_driver.c +@@ -45,6 +45,7 @@ + #include "libxl_domain.h" + #include "libxl_driver.h" + #include "libxl_conf.h" ++#include "libxl_migration.h" + #include "xen_xm.h" + #include "xen_sxpr.h" + #include "virtypedparam.h" +@@ -209,6 +210,7 @@ libxlStateCleanup(void) + virObjectUnref(libxl_driver->xmlopt); + virObjectUnref(libxl_driver->domains); + virObjectUnref(libxl_driver->reservedVNCPorts); ++ virObjectUnref(libxl_driver->migrationPorts); + + virObjectEventStateFree(libxl_driver->domainEventState); + virSysinfoDefFree(libxl_driver->hostsysinfo); +@@ -301,6 +303,13 @@ libxlStateInitialize(bool privileged, + LIBXL_VNC_PORT_MAX))) + goto error; + ++ /* Allocate bitmap for migration port reservation */ ++ if (!(libxl_driver->migrationPorts = ++ virPortAllocatorNew(_("migration"), ++ LIBXL_MIGRATION_PORT_MIN, ++ LIBXL_MIGRATION_PORT_MAX))) ++ goto error; ++ + if (!(libxl_driver->domains = virDomainObjListNew())) + goto error; + +@@ -4155,6 +4164,7 @@ libxlConnectSupportsFeature(virConnectPt + + switch (feature) { + case VIR_DRV_FEATURE_TYPED_PARAM_STRING: ++ case VIR_DRV_FEATURE_MIGRATION_PARAMS: + return 1; + default: + return 0; +@@ -4333,6 +4343,226 @@ libxlNodeDeviceReset(virNodeDevicePtr de + return ret; + } + ++static char * ++libxlDomainMigrateBegin3Params(virDomainPtr domain, ++ virTypedParameterPtr params, ++ int nparams, ++ char **cookieout ATTRIBUTE_UNUSED, ++ int *cookieoutlen ATTRIBUTE_UNUSED, ++ unsigned int flags) ++{ ++ const char *xmlin = NULL; ++ virDomainObjPtr vm = NULL; ++ ++ virCheckFlags(LIBXL_MIGRATION_FLAGS, NULL); ++ if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0) ++ return NULL; ++ ++ if (virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_DEST_XML, ++ &xmlin) < 0) ++ return NULL; ++ ++ if (!(vm = libxlDomObjFromDomain(domain))) ++ return NULL; ++ ++ if (virDomainMigrateBegin3ParamsEnsureACL(domain->conn, vm->def) < 0) { ++ virObjectUnlock(vm); ++ return NULL; ++ } ++ ++ if (!virDomainObjIsActive(vm)) { ++ virReportError(VIR_ERR_OPERATION_INVALID, ++ "%s", _("domain is not running")); ++ virObjectUnlock(vm); ++ return NULL; ++ } ++ ++ return libxlDomainMigrationBegin(domain->conn, vm, xmlin); ++} ++ ++static int ++libxlDomainMigratePrepare3Params(virConnectPtr dconn, ++ virTypedParameterPtr params, ++ int nparams, ++ const char *cookiein ATTRIBUTE_UNUSED, ++ int cookieinlen ATTRIBUTE_UNUSED, ++ char **cookieout ATTRIBUTE_UNUSED, ++ int *cookieoutlen ATTRIBUTE_UNUSED, ++ char **uri_out, ++ unsigned int flags) ++{ ++ libxlDriverPrivatePtr driver = dconn->privateData; ++ virDomainDefPtr def = NULL; ++ const char *dom_xml = NULL; ++ const char *dname = NULL; ++ const char *uri_in = NULL; ++ ++ virCheckFlags(LIBXL_MIGRATION_FLAGS, -1); ++ if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0) ++ goto error; ++ ++ if (virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_DEST_XML, ++ &dom_xml) < 0 || ++ virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_DEST_NAME, ++ &dname) < 0 || ++ virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_URI, ++ &uri_in) < 0) ++ ++ goto error; ++ ++ if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname))) ++ goto error; ++ ++ if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) ++ goto error; ++ ++ if (libxlDomainMigrationPrepare(dconn, def, uri_in, uri_out) < 0) ++ goto error; ++ ++ return 0; ++ ++ error: ++ virDomainDefFree(def); ++ return -1; ++} ++ ++static int ++libxlDomainMigratePerform3Params(virDomainPtr dom, ++ const char *dconnuri, ++ virTypedParameterPtr params, ++ int nparams, ++ const char *cookiein ATTRIBUTE_UNUSED, ++ int cookieinlen ATTRIBUTE_UNUSED, ++ char **cookieout ATTRIBUTE_UNUSED, ++ int *cookieoutlen ATTRIBUTE_UNUSED, ++ unsigned int flags) ++{ ++ libxlDriverPrivatePtr driver = dom->conn->privateData; ++ virDomainObjPtr vm = NULL; ++ const char *dom_xml = NULL; ++ const char *dname = NULL; ++ const char *uri = NULL; ++ int ret = -1; ++ ++ virCheckFlags(LIBXL_MIGRATION_FLAGS, -1); ++ if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0) ++ goto cleanup; ++ ++ if (virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_DEST_XML, ++ &dom_xml) < 0 || ++ virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_DEST_NAME, ++ &dname) < 0 || ++ virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_URI, ++ &uri) < 0) ++ ++ goto cleanup; ++ ++ if (!(vm = libxlDomObjFromDomain(dom))) ++ goto cleanup; ++ ++ if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0) ++ goto cleanup; ++ ++ if (libxlDomainMigrationPerform(driver, vm, dom_xml, dconnuri, ++ uri, dname, flags) < 0) { ++ /* Job terminated and vm unlocked if MigrationPerform failed */ ++ vm = NULL; ++ goto cleanup; ++ } ++ ++ ret = 0; ++ ++ cleanup: ++ if (vm) ++ virObjectUnlock(vm); ++ return ret; ++} ++ ++static virDomainPtr ++libxlDomainMigrateFinish3Params(virConnectPtr dconn, ++ virTypedParameterPtr params, ++ int nparams, ++ const char *cookiein ATTRIBUTE_UNUSED, ++ int cookieinlen ATTRIBUTE_UNUSED, ++ char **cookieout ATTRIBUTE_UNUSED, ++ int *cookieoutlen ATTRIBUTE_UNUSED, ++ unsigned int flags, ++ int cancelled) ++{ ++ libxlDriverPrivatePtr driver = dconn->privateData; ++ virDomainObjPtr vm = NULL; ++ const char *dname = NULL; ++ ++ virCheckFlags(LIBXL_MIGRATION_FLAGS, NULL); ++ if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0) ++ return NULL; ++ ++ if (virTypedParamsGetString(params, nparams, ++ VIR_MIGRATE_PARAM_DEST_NAME, ++ &dname) < 0) ++ return NULL; ++ ++ if (!dname || ++ !(vm = virDomainObjListFindByName(driver->domains, dname))) { ++ /* Migration obviously failed if the domain doesn't exist */ ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ _("Migration failed. No domain on destination host " ++ "with matching name '%s'"), ++ NULLSTR(dname)); ++ return NULL; ++ } ++ ++ if (virDomainMigrateFinish3ParamsEnsureACL(dconn, vm->def) < 0) { ++ virObjectUnlock(vm); ++ return NULL; ++ } ++ ++ if (!virDomainObjIsActive(vm)) { ++ /* Migration failed if domain is inactive */ ++ virReportError(VIR_ERR_OPERATION_FAILED, ++ "%s", _("Migration failed. Domain is not running " ++ "on destination host")); ++ virObjectUnlock(vm); ++ return NULL; ++ } ++ ++ return libxlDomainMigrationFinish(dconn, vm, flags, cancelled); ++} ++ ++static int ++libxlDomainMigrateConfirm3Params(virDomainPtr domain, ++ virTypedParameterPtr params, ++ int nparams, ++ const char *cookiein ATTRIBUTE_UNUSED, ++ int cookieinlen ATTRIBUTE_UNUSED, ++ unsigned int flags, ++ int cancelled) ++{ ++ libxlDriverPrivatePtr driver = domain->conn->privateData; ++ virDomainObjPtr vm = NULL; ++ ++ virCheckFlags(LIBXL_MIGRATION_FLAGS, -1); ++ if (virTypedParamsValidate(params, nparams, LIBXL_MIGRATION_PARAMETERS) < 0) ++ return -1; ++ ++ if (!(vm = libxlDomObjFromDomain(domain))) ++ return -1; ++ ++ if (virDomainMigrateConfirm3ParamsEnsureACL(domain->conn, vm->def) < 0) { ++ virObjectUnlock(vm); ++ return -1; ++ } ++ ++ return libxlDomainMigrationConfirm(driver, vm, flags, cancelled); ++} ++ + + static virDriver libxlDriver = { + .no = VIR_DRV_LIBXL, +@@ -4423,6 +4653,11 @@ static virDriver libxlDriver = { + .nodeDeviceDetachFlags = libxlNodeDeviceDetachFlags, /* 1.2.3 */ + .nodeDeviceReAttach = libxlNodeDeviceReAttach, /* 1.2.3 */ + .nodeDeviceReset = libxlNodeDeviceReset, /* 1.2.3 */ ++ .domainMigrateBegin3Params = libxlDomainMigrateBegin3Params, /* 1.2.3 */ ++ .domainMigratePrepare3Params = libxlDomainMigratePrepare3Params, /* 1.2.3 */ ++ .domainMigratePerform3Params = libxlDomainMigratePerform3Params, /* 1.2.3 */ ++ .domainMigrateFinish3Params = libxlDomainMigrateFinish3Params, /* 1.2.3 */ ++ .domainMigrateConfirm3Params = libxlDomainMigrateConfirm3Params, /* 1.2.3 */ + }; + + static virStateDriver libxlStateDriver = { +Index: libvirt-1.2.4/src/libxl/libxl_migration.c +=================================================================== +--- /dev/null ++++ libvirt-1.2.4/src/libxl/libxl_migration.c +@@ -0,0 +1,577 @@ ++/* ++ * libxl_migration.c: methods for handling migration with libxenlight ++ * ++ * Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see ++ * . ++ * ++ * Authors: ++ * Jim Fehlig ++ * Chunyan Liu ++ */ ++ ++#include ++ ++#include "internal.h" ++#include "virlog.h" ++#include "virerror.h" ++#include "virconf.h" ++#include "datatypes.h" ++#include "virfile.h" ++#include "viralloc.h" ++#include "viruuid.h" ++#include "vircommand.h" ++#include "virstring.h" ++#include "virobject.h" ++#include "rpc/virnetsocket.h" ++#include "libxl_domain.h" ++#include "libxl_driver.h" ++#include "libxl_conf.h" ++#include "libxl_migration.h" ++ ++#define VIR_FROM_THIS VIR_FROM_LIBXL ++ ++VIR_LOG_INIT("libxl.libxl_migration"); ++ ++typedef struct _libxlMigrationDstArgs { ++ virObject parent; ++ ++ virConnectPtr conn; ++ virDomainObjPtr vm; ++ ++ /* for freeing listen sockets */ ++ virNetSocketPtr *socks; ++ size_t nsocks; ++} libxlMigrationDstArgs; ++ ++static virClassPtr libxlMigrationDstArgsClass; ++ ++static void ++libxlMigrationDstArgsDispose(void *obj) ++{ ++ libxlMigrationDstArgs *args = obj; ++ ++ VIR_FREE(args->socks); ++} ++ ++static int ++libxlMigrationDstArgsOnceInit(void) ++{ ++ if (!(libxlMigrationDstArgsClass = virClassNew(virClassForObject(), ++ "libxlMigrationDstArgs", ++ sizeof(libxlMigrationDstArgs), ++ libxlMigrationDstArgsDispose))) ++ return -1; ++ ++ return 0; ++} ++ ++VIR_ONCE_GLOBAL_INIT(libxlMigrationDstArgs) ++ ++static void ++libxlDoMigrateReceive(virNetSocketPtr sock, ++ int events ATTRIBUTE_UNUSED, ++ void *opaque) ++{ ++ libxlMigrationDstArgs *args = opaque; ++ virConnectPtr conn = args->conn; ++ virDomainObjPtr vm = args->vm; ++ virNetSocketPtr *socks = args->socks; ++ size_t nsocks = args->nsocks; ++ libxlDriverPrivatePtr driver = conn->privateData; ++ virNetSocketPtr client_sock; ++ int recvfd = -1; ++ size_t i; ++ int ret; ++ ++ virNetSocketAccept(sock, &client_sock); ++ if (client_sock == NULL) { ++ virReportError(VIR_ERR_OPERATION_INVALID, "%s", ++ _("Fail to accept migration connection")); ++ goto cleanup; ++ } ++ VIR_DEBUG("Accepted migration connection\n"); ++ recvfd = virNetSocketDupFD(client_sock, true); ++ virObjectUnref(client_sock); ++ ++ virObjectLock(vm); ++ ret = libxlDomainStart(driver, vm, false, recvfd); ++ virObjectUnlock(vm); ++ ++ if (ret < 0 && !vm->persistent) ++ virDomainObjListRemove(driver->domains, vm); ++ ++ cleanup: ++ /* Remove all listen socks from event handler, and close them. */ ++ for (i = 0; i < nsocks; i++) { ++ virNetSocketUpdateIOCallback(socks[i], 0); ++ virNetSocketRemoveIOCallback(socks[i]); ++ virNetSocketClose(socks[i]); ++ virObjectUnref(socks[i]); ++ } ++ ++ VIR_FORCE_CLOSE(recvfd); ++} ++ ++static int ++libxlDoMigrateSend(libxlDriverPrivatePtr driver, ++ virDomainObjPtr vm, ++ unsigned long flags, ++ int sockfd) ++{ ++ libxlDomainObjPrivatePtr priv; ++ libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); ++ virObjectEventPtr event = NULL; ++ int xl_flags = 0; ++ int ret; ++ ++ if (flags & VIR_MIGRATE_LIVE) ++ xl_flags = LIBXL_SUSPEND_LIVE; ++ ++ priv = vm->privateData; ++ ret = libxl_domain_suspend(priv->ctx, vm->def->id, sockfd, ++ xl_flags, NULL); ++ if (ret != 0) { ++ /* attempt to resume the domain on failure */ ++ if (libxl_domain_resume(priv->ctx, vm->def->id, 0, 0) != 0) { ++ VIR_DEBUG("Failed to resume domain following failed migration"); ++ virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, ++ VIR_DOMAIN_PAUSED_MIGRATION); ++ event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, ++ VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED); ++ ignore_value(virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm)); ++ } ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ++ _("Failed to send migration data to destination host")); ++ ret = -1; ++ goto cleanup; ++ } ++ ++ cleanup: ++ if (event) ++ libxlDomainEventQueue(driver, event); ++ virObjectUnref(cfg); ++ return ret; ++} ++ ++static bool ++libxlDomainMigrationIsAllowed(virDomainDefPtr def) ++{ ++ /* Migration is not allowed if definition contains any hostdevs */ ++ if (def->nhostdevs > 0) { ++ virReportError(VIR_ERR_OPERATION_INVALID, "%s", ++ _("domain has assigned host devices")); ++ return false; ++ } ++ ++ return true; ++} ++ ++char * ++libxlDomainMigrationBegin(virConnectPtr conn, ++ virDomainObjPtr vm, ++ const char *xmlin) ++{ ++ libxlDriverPrivatePtr driver = conn->privateData; ++ libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); ++ virDomainDefPtr tmpdef = NULL; ++ virDomainDefPtr def; ++ char *xml = NULL; ++ ++ if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_MODIFY) < 0) ++ goto cleanup; ++ ++ if (xmlin) { ++ if (!(tmpdef = virDomainDefParseString(xmlin, cfg->caps, ++ driver->xmlopt, ++ 1 << VIR_DOMAIN_VIRT_XEN, ++ VIR_DOMAIN_XML_INACTIVE))) ++ goto endjob; ++ ++ def = tmpdef; ++ } else { ++ def = vm->def; ++ } ++ ++ if (!libxlDomainMigrationIsAllowed(def)) ++ goto endjob; ++ ++ xml = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE); ++ ++ cleanup: ++ if (vm) ++ virObjectUnlock(vm); ++ ++ virDomainDefFree(tmpdef); ++ virObjectUnref(cfg); ++ return xml; ++ ++ endjob: ++ if (!libxlDomainObjEndJob(driver, vm)) ++ vm = NULL; ++ goto cleanup; ++} ++ ++virDomainDefPtr ++libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver, ++ const char *dom_xml, ++ const char *dname) ++{ ++ libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); ++ virDomainDefPtr def; ++ char *name = NULL; ++ ++ if (!dom_xml) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ++ _("no domain XML passed")); ++ return NULL; ++ } ++ ++ if (!(def = virDomainDefParseString(dom_xml, cfg->caps, driver->xmlopt, ++ 1 << VIR_DOMAIN_VIRT_XEN, ++ VIR_DOMAIN_XML_INACTIVE))) ++ goto cleanup; ++ ++ if (dname) { ++ name = def->name; ++ if (VIR_STRDUP(def->name, dname) < 0) { ++ virDomainDefFree(def); ++ def = NULL; ++ } ++ } ++ ++ cleanup: ++ virObjectUnref(cfg); ++ VIR_FREE(name); ++ return def; ++} ++ ++int ++libxlDomainMigrationPrepare(virConnectPtr dconn, ++ virDomainDefPtr def, ++ const char *uri_in, ++ char **uri_out) ++{ ++ libxlDriverPrivatePtr driver = dconn->privateData; ++ virDomainObjPtr vm = NULL; ++ char *hostname = NULL; ++ unsigned short port; ++ char portstr[100]; ++ virURIPtr uri = NULL; ++ virNetSocketPtr *socks = NULL; ++ size_t nsocks = 0; ++ int nsocks_listen = 0; ++ libxlMigrationDstArgs *args; ++ size_t i; ++ int ret = -1; ++ ++ if (!(vm = virDomainObjListAdd(driver->domains, def, ++ driver->xmlopt, ++ VIR_DOMAIN_OBJ_LIST_ADD_LIVE | ++ VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, ++ NULL))) ++ goto cleanup; ++ ++ /* Create socket connection to receive migration data */ ++ if (!uri_in) { ++ if ((hostname = virGetHostname()) == NULL) ++ goto cleanup; ++ ++ if (STRPREFIX(hostname, "localhost")) { ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", ++ _("hostname on destination resolved to localhost," ++ " but migration requires an FQDN")); ++ goto cleanup; ++ } ++ ++ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) ++ goto cleanup; ++ ++ if (virAsprintf(uri_out, "tcp://%s:%d", hostname, port) < 0) ++ goto cleanup; ++ } else { ++ if (!(STRPREFIX(uri_in, "tcp://"))) { ++ /* not full URI, add prefix tcp:// */ ++ char *tmp; ++ if (virAsprintf(&tmp, "tcp://%s", uri_in) < 0) ++ goto cleanup; ++ uri = virURIParse(tmp); ++ VIR_FREE(tmp); ++ } else { ++ uri = virURIParse(uri_in); ++ } ++ ++ if (uri == NULL) { ++ virReportError(VIR_ERR_INVALID_ARG, ++ _("unable to parse URI: %s"), ++ uri_in); ++ goto cleanup; ++ } ++ ++ if (uri->server == NULL) { ++ virReportError(VIR_ERR_INVALID_ARG, ++ _("missing host in migration URI: %s"), ++ uri_in); ++ goto cleanup; ++ } else { ++ hostname = uri->server; ++ } ++ ++ if (uri->port == 0) { ++ if (virPortAllocatorAcquire(driver->migrationPorts, &port) < 0) ++ goto cleanup; ++ ++ } else { ++ port = uri->port; ++ } ++ ++ if (virAsprintf(uri_out, "tcp://%s:%d", hostname, port) < 0) ++ goto cleanup; ++ } ++ ++ snprintf(portstr, sizeof(portstr), "%d", port); ++ ++ if (virNetSocketNewListenTCP(hostname, portstr, &socks, &nsocks) < 0) { ++ virReportError(VIR_ERR_OPERATION_FAILED, "%s", ++ _("Fail to create socket for incoming migration")); ++ goto cleanup; ++ } ++ ++ if (libxlMigrationDstArgsInitialize() < 0) ++ goto cleanup; ++ ++ if (!(args = virObjectNew(libxlMigrationDstArgsClass))) ++ goto cleanup; ++ ++ args->conn = dconn; ++ args->vm = vm; ++ args->socks = socks; ++ args->nsocks = nsocks; ++ ++ for (i = 0; i < nsocks; i++) { ++ if (virNetSocketSetBlocking(socks[i], true) < 0) ++ continue; ++ ++ if (virNetSocketListen(socks[i], 1) < 0) ++ continue; ++ ++ if (virNetSocketAddIOCallback(socks[i], ++ VIR_EVENT_HANDLE_READABLE, ++ libxlDoMigrateReceive, ++ args, ++ virObjectFreeCallback) < 0) ++ continue; ++ ++ /* ++ * Successfully added sock to event loop. Take a ref on args to ++ * ensure it is not freed until sock is removed from the event loop. ++ * Ref is dropped in virObjectFreeCallback after being removed ++ * from the event loop. ++ */ ++ virObjectRef(args); ++ nsocks_listen++; ++ } ++ ++ /* Done with args in this function, drop reference */ ++ virObjectUnref(args); ++ ++ if (!nsocks_listen) ++ goto cleanup; ++ ++ ret = 0; ++ goto done; ++ ++ cleanup: ++ for (i = 0; i < nsocks; i++) { ++ virNetSocketClose(socks[i]); ++ virObjectUnref(socks[i]); ++ } ++ ++ done: ++ virURIFree(uri); ++ if (vm) ++ virObjectUnlock(vm); ++ return ret; ++} ++ ++int ++libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, ++ virDomainObjPtr vm, ++ const char *dom_xml ATTRIBUTE_UNUSED, ++ const char *dconnuri ATTRIBUTE_UNUSED, ++ const char *uri_str, ++ const char *dname ATTRIBUTE_UNUSED, ++ unsigned int flags) ++{ ++ char *hostname = NULL; ++ unsigned short port = 0; ++ char portstr[100]; ++ virURIPtr uri = NULL; ++ virNetSocketPtr sock; ++ int sockfd = -1; ++ int saved_errno = EINVAL; ++ int ret = -1; ++ ++ /* parse dst host:port from uri */ ++ uri = virURIParse(uri_str); ++ if (uri == NULL || uri->server == NULL || uri->port == 0) ++ goto cleanup; ++ ++ hostname = uri->server; ++ port = uri->port; ++ snprintf(portstr, sizeof(portstr), "%d", port); ++ ++ /* socket connect to dst host:port */ ++ if (virNetSocketNewConnectTCP(hostname, portstr, &sock) < 0) { ++ virReportSystemError(saved_errno, ++ _("unable to connect to '%s:%s'"), ++ hostname, portstr); ++ goto cleanup; ++ } ++ ++ if (virNetSocketSetBlocking(sock, true) < 0) { ++ virObjectUnref(sock); ++ goto cleanup; ++ } ++ ++ sockfd = virNetSocketDupFD(sock, true); ++ virObjectUnref(sock); ++ ++ /* suspend vm and send saved data to dst through socket fd */ ++ virObjectUnlock(vm); ++ ret = libxlDoMigrateSend(driver, vm, flags, sockfd); ++ virObjectLock(vm); ++ ++ cleanup: ++ /* If failure, terminate the job started in MigrationBegin */ ++ if (ret == -1) { ++ if (libxlDomainObjEndJob(driver, vm)) ++ virObjectUnlock(vm); ++ } ++ VIR_FORCE_CLOSE(sockfd); ++ virURIFree(uri); ++ return ret; ++} ++ ++virDomainPtr ++libxlDomainMigrationFinish(virConnectPtr dconn, ++ virDomainObjPtr vm, ++ unsigned int flags, ++ int cancelled) ++{ ++ libxlDriverPrivatePtr driver = dconn->privateData; ++ libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); ++ libxlDomainObjPrivatePtr priv = vm->privateData; ++ virObjectEventPtr event = NULL; ++ virDomainPtr dom = NULL; ++ ++ virPortAllocatorRelease(driver->migrationPorts, priv->migrationPort); ++ priv->migrationPort = 0; ++ ++ if (cancelled) ++ goto cleanup; ++ ++ if (!(flags & VIR_MIGRATE_PAUSED)) { ++ if (libxl_domain_unpause(priv->ctx, vm->def->id) != 0) { ++ virReportError(VIR_ERR_OPERATION_FAILED, "%s", ++ _("Failed to unpause domain")); ++ goto cleanup; ++ } ++ ++ virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, ++ VIR_DOMAIN_RUNNING_MIGRATED); ++ event = virDomainEventLifecycleNewFromObj(vm, ++ VIR_DOMAIN_EVENT_RESUMED, ++ VIR_DOMAIN_EVENT_RESUMED_MIGRATED); ++ } else { ++ virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER); ++ event = virDomainEventLifecycleNewFromObj(vm, ++ VIR_DOMAIN_EVENT_SUSPENDED, ++ VIR_DOMAIN_EVENT_SUSPENDED_PAUSED); ++ } ++ ++ if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) ++ goto cleanup; ++ ++ dom = virGetDomain(dconn, vm->def->name, vm->def->uuid); ++ ++ if (dom == NULL) { ++ libxl_domain_destroy(priv->ctx, vm->def->id, NULL); ++ libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); ++ event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, ++ VIR_DOMAIN_EVENT_STOPPED_FAILED); ++ libxlDomainEventQueue(driver, event); ++ } ++ ++ cleanup: ++ if (event) ++ libxlDomainEventQueue(driver, event); ++ if (vm) ++ virObjectUnlock(vm); ++ virObjectUnref(cfg); ++ return dom; ++} ++ ++int ++libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver, ++ virDomainObjPtr vm, ++ unsigned int flags, ++ int cancelled) ++{ ++ libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); ++ libxlDomainObjPrivatePtr priv = vm->privateData; ++ virObjectEventPtr event = NULL; ++ int ret = -1; ++ ++ if (cancelled) { ++ if (libxl_domain_resume(priv->ctx, vm->def->id, 1, 0) == 0) { ++ ret = 0; ++ } else { ++ VIR_DEBUG("Unable to resume domain '%s' after failed migration", ++ vm->def->name); ++ virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, ++ VIR_DOMAIN_PAUSED_MIGRATION); ++ event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_SUSPENDED, ++ VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED); ++ ignore_value(virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm)); ++ } ++ goto cleanup; ++ } ++ ++ libxl_domain_destroy(priv->ctx, vm->def->id, NULL); ++ libxlDomainCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_MIGRATED); ++ event = virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED, ++ VIR_DOMAIN_EVENT_STOPPED_MIGRATED); ++ ++ VIR_DEBUG("Domain '%s' successfully migrated", vm->def->name); ++ ++ if (flags & VIR_MIGRATE_UNDEFINE_SOURCE) ++ virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm); ++ ++ if (!vm->persistent || (flags & VIR_MIGRATE_UNDEFINE_SOURCE)) ++ virDomainObjListRemove(driver->domains, vm); ++ ++ ret = 0; ++ ++ cleanup: ++ if (!libxlDomainObjEndJob(driver, vm)) ++ vm = NULL; ++ if (event) ++ libxlDomainEventQueue(driver, event); ++ if (vm) ++ virObjectUnlock(vm); ++ virObjectUnref(cfg); ++ return ret; ++} +Index: libvirt-1.2.4/src/libxl/libxl_migration.h +=================================================================== +--- /dev/null ++++ libvirt-1.2.4/src/libxl/libxl_migration.h +@@ -0,0 +1,78 @@ ++/* ++ * libxl_migration.h: methods for handling migration with libxenlight ++ * ++ * Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see ++ * . ++ * ++ * Authors: ++ * Jim Fehlig ++ */ ++ ++#ifndef LIBXL_MIGRATION_H ++# define LIBXL_MIGRATION_H ++ ++# include "libxl_conf.h" ++ ++# define LIBXL_MIGRATION_FLAGS \ ++ (VIR_MIGRATE_LIVE | \ ++ VIR_MIGRATE_UNDEFINE_SOURCE | \ ++ VIR_MIGRATE_PAUSED) ++ ++/* All supported migration parameters and their types. */ ++# define LIBXL_MIGRATION_PARAMETERS \ ++ VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \ ++ VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \ ++ VIR_MIGRATE_PARAM_DEST_XML, VIR_TYPED_PARAM_STRING, \ ++ NULL ++ ++char * ++libxlDomainMigrationBegin(virConnectPtr conn, ++ virDomainObjPtr vm, ++ const char *xmlin); ++ ++virDomainDefPtr ++libxlDomainMigrationPrepareDef(libxlDriverPrivatePtr driver, ++ const char *dom_xml, ++ const char *dname); ++ ++int ++libxlDomainMigrationPrepare(virConnectPtr dconn, ++ virDomainDefPtr def, ++ const char *uri_in, ++ char **uri_out); ++ ++int ++libxlDomainMigrationPerform(libxlDriverPrivatePtr driver, ++ virDomainObjPtr vm, ++ const char *dom_xml, ++ const char *dconnuri, ++ const char *uri_str, ++ const char *dname, ++ unsigned int flags); ++ ++virDomainPtr ++libxlDomainMigrationFinish(virConnectPtr dconn, ++ virDomainObjPtr vm, ++ unsigned int flags, ++ int cancelled); ++ ++int ++libxlDomainMigrationConfirm(libxlDriverPrivatePtr driver, ++ virDomainObjPtr vm, ++ unsigned int flags, ++ int cancelled); ++ ++#endif /* LIBXL_DRIVER_H */ diff --git a/support-managed-pci-xen-driver.patch b/support-managed-pci-xen-driver.patch index 5909ccb..137b542 100644 --- a/support-managed-pci-xen-driver.patch +++ b/support-managed-pci-xen-driver.patch @@ -8,10 +8,10 @@ Subject: [PATCH] support managed pci devices in xen driver src/xenxs/xen_xm.c | 28 +++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 15 deletions(-) -Index: libvirt-1.2.3/src/xenxs/xen_sxpr.c +Index: libvirt-1.2.4/src/xenxs/xen_sxpr.c =================================================================== ---- libvirt-1.2.3.orig/src/xenxs/xen_sxpr.c -+++ libvirt-1.2.3/src/xenxs/xen_sxpr.c +--- libvirt-1.2.4.orig/src/xenxs/xen_sxpr.c ++++ libvirt-1.2.4/src/xenxs/xen_sxpr.c @@ -997,6 +997,7 @@ xenParseSxprPCI(virDomainDefPtr def, int busID; int slotID; @@ -78,10 +78,10 @@ Index: libvirt-1.2.3/src/xenxs/xen_sxpr.c xenFormatSxprPCI(def->hostdevs[i], buf); } } -Index: libvirt-1.2.3/src/xenxs/xen_xm.c +Index: libvirt-1.2.4/src/xenxs/xen_xm.c =================================================================== ---- libvirt-1.2.3.orig/src/xenxs/xen_xm.c -+++ libvirt-1.2.3/src/xenxs/xen_xm.c +--- libvirt-1.2.4.orig/src/xenxs/xen_xm.c ++++ libvirt-1.2.4/src/xenxs/xen_xm.c @@ -807,6 +807,8 @@ xenParseXM(virConfPtr conf, int xendConf int busID; int slotID; diff --git a/suse-qemu-conf.patch b/suse-qemu-conf.patch index fd93293..36ddb61 100644 --- a/suse-qemu-conf.patch +++ b/suse-qemu-conf.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/src/qemu/qemu.conf +Index: libvirt-1.2.4/src/qemu/qemu.conf =================================================================== ---- libvirt-1.2.3.orig/src/qemu/qemu.conf -+++ libvirt-1.2.3/src/qemu/qemu.conf +--- libvirt-1.2.4.orig/src/qemu/qemu.conf ++++ libvirt-1.2.4/src/qemu/qemu.conf @@ -200,7 +200,16 @@ # a special value; security_driver can be set to that value in # isolation, but it cannot appear in a list of drivers. diff --git a/systemd-service-xen.patch b/systemd-service-xen.patch index 82ed548..56cf0cc 100644 --- a/systemd-service-xen.patch +++ b/systemd-service-xen.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/daemon/libvirtd.service.in +Index: libvirt-1.2.4/daemon/libvirtd.service.in =================================================================== ---- libvirt-1.2.3.orig/daemon/libvirtd.service.in -+++ libvirt-1.2.3/daemon/libvirtd.service.in +--- libvirt-1.2.4.orig/daemon/libvirtd.service.in ++++ libvirt-1.2.4/daemon/libvirtd.service.in @@ -10,6 +10,8 @@ After=network.target After=dbus.service After=iscsid.service diff --git a/virtlockd-init-script.patch b/virtlockd-init-script.patch index 81b3921..bf2e409 100644 --- a/virtlockd-init-script.patch +++ b/virtlockd-init-script.patch @@ -1,9 +1,9 @@ Adjust virtlockd init files to conform to SUSE standards -Index: libvirt-1.2.3/src/locking/virtlockd.sysconf +Index: libvirt-1.2.4/src/locking/virtlockd.sysconf =================================================================== ---- libvirt-1.2.3.orig/src/locking/virtlockd.sysconf -+++ libvirt-1.2.3/src/locking/virtlockd.sysconf +--- libvirt-1.2.4.orig/src/locking/virtlockd.sysconf ++++ libvirt-1.2.4/src/locking/virtlockd.sysconf @@ -1,3 +1,7 @@ +## Path: System/Virtualization/virtlockd + @@ -12,10 +12,10 @@ Index: libvirt-1.2.3/src/locking/virtlockd.sysconf # # Pass extra arguments to virtlockd #VIRTLOCKD_ARGS= -Index: libvirt-1.2.3/src/locking/virtlockd.init.in +Index: libvirt-1.2.4/src/locking/virtlockd.init.in =================================================================== ---- libvirt-1.2.3.orig/src/locking/virtlockd.init.in -+++ libvirt-1.2.3/src/locking/virtlockd.init.in +--- libvirt-1.2.4.orig/src/locking/virtlockd.init.in ++++ libvirt-1.2.4/src/locking/virtlockd.init.in @@ -4,12 +4,14 @@ # http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV # diff --git a/xen-name-for-devid.patch b/xen-name-for-devid.patch index 5f7073f..77045be 100644 --- a/xen-name-for-devid.patch +++ b/xen-name-for-devid.patch @@ -14,10 +14,10 @@ is inactive. We obviously can't search xenstore when the domain is inactive. -Index: libvirt-1.2.3/src/xen/xend_internal.c +Index: libvirt-1.2.4/src/xen/xend_internal.c =================================================================== ---- libvirt-1.2.3.orig/src/xen/xend_internal.c -+++ libvirt-1.2.3/src/xen/xend_internal.c +--- libvirt-1.2.4.orig/src/xen/xend_internal.c ++++ libvirt-1.2.4/src/xen/xend_internal.c @@ -72,7 +72,7 @@ VIR_LOG_INIT("xen.xend_internal"); #define XEND_RCV_BUF_MAX_LEN (256 * 1024) diff --git a/xen-pv-cdrom.patch b/xen-pv-cdrom.patch index e7b3d54..ff925a7 100644 --- a/xen-pv-cdrom.patch +++ b/xen-pv-cdrom.patch @@ -1,7 +1,7 @@ -Index: libvirt-1.2.3/src/xenxs/xen_sxpr.c +Index: libvirt-1.2.4/src/xenxs/xen_sxpr.c =================================================================== ---- libvirt-1.2.3.orig/src/xenxs/xen_sxpr.c -+++ libvirt-1.2.3/src/xenxs/xen_sxpr.c +--- libvirt-1.2.4.orig/src/xenxs/xen_sxpr.c ++++ libvirt-1.2.4/src/xenxs/xen_sxpr.c @@ -332,7 +332,7 @@ xenParseSxprChar(const char *value, static int xenParseSxprDisks(virDomainDefPtr def, From 951275e87c7889e4b1c9c247c64a546c8acc6b4256150414c4e9453a393d0d12 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Wed, 7 May 2014 16:21:44 +0000 Subject: [PATCH 3/3] re-enable add-nocow-to-vol-xml.patch OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=370 --- add-nocow-to-vol-xml.patch | 64 ++++++++++++++++++++++---------------- libvirt.spec | 4 +-- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/add-nocow-to-vol-xml.patch b/add-nocow-to-vol-xml.patch index acbc9ab..ccf7ee5 100644 --- a/add-nocow-to-vol-xml.patch +++ b/add-nocow-to-vol-xml.patch @@ -1,8 +1,18 @@ -Index: libvirt-1.2.3/docs/schemas/storagevol.rng +commit ccc0b45917fa76a77ff83f1ddfd30836c8c3805e +Author: Chunyan Liu +Date: Wed May 7 12:45:40 2014 +0800 + + add nocow to vol xml + + Updated patch. Rebase to git master. + + Signed-off-by: Chunyan Liu + +Index: libvirt-1.2.4/docs/schemas/storagevol.rng =================================================================== ---- libvirt-1.2.3.orig/docs/schemas/storagevol.rng -+++ libvirt-1.2.3/docs/schemas/storagevol.rng -@@ -139,6 +139,11 @@ +--- libvirt-1.2.4.orig/docs/schemas/storagevol.rng ++++ libvirt-1.2.4/docs/schemas/storagevol.rng +@@ -138,6 +138,11 @@ @@ -14,11 +24,11 @@ Index: libvirt-1.2.3/docs/schemas/storagevol.rng -Index: libvirt-1.2.3/src/conf/storage_conf.c +Index: libvirt-1.2.4/src/conf/storage_conf.c =================================================================== ---- libvirt-1.2.3.orig/src/conf/storage_conf.c -+++ libvirt-1.2.3/src/conf/storage_conf.c -@@ -1401,6 +1401,9 @@ virStorageVolDefParseXML(virStoragePoolD +--- libvirt-1.2.4.orig/src/conf/storage_conf.c ++++ libvirt-1.2.4/src/conf/storage_conf.c +@@ -1395,6 +1395,9 @@ virStorageVolDefParseXML(virStoragePoolD virStringFreeList(version); } @@ -28,22 +38,10 @@ Index: libvirt-1.2.3/src/conf/storage_conf.c if (options->featureFromString && virXPathNode("./target/features", ctxt)) { if ((n = virXPathNodeSet("./target/features/*", ctxt, &nodes)) < 0) goto error; -Index: libvirt-1.2.3/src/conf/storage_conf.h +Index: libvirt-1.2.4/src/storage/storage_backend.c =================================================================== ---- libvirt-1.2.3.orig/src/conf/storage_conf.h -+++ libvirt-1.2.3/src/conf/storage_conf.h -@@ -90,6 +90,7 @@ struct _virStorageVolTarget { - virStorageEncryptionPtr encryption; - virBitmapPtr features; - char *compat; -+ bool nocow; - }; - - typedef struct _virStorageVolDef virStorageVolDef; -Index: libvirt-1.2.3/src/storage/storage_backend.c -=================================================================== ---- libvirt-1.2.3.orig/src/storage/storage_backend.c -+++ libvirt-1.2.3/src/storage/storage_backend.c +--- libvirt-1.2.4.orig/src/storage/storage_backend.c ++++ libvirt-1.2.4/src/storage/storage_backend.c @@ -37,6 +37,9 @@ #ifdef __linux__ # include @@ -54,7 +52,7 @@ Index: libvirt-1.2.3/src/storage/storage_backend.c #endif #if WITH_SELINUX -@@ -449,6 +452,21 @@ virStorageBackendCreateRaw(virConnectPtr +@@ -452,6 +455,21 @@ virStorageBackendCreateRaw(virConnectPtr goto cleanup; } @@ -76,7 +74,7 @@ Index: libvirt-1.2.3/src/storage/storage_backend.c if ((ret = createRawFile(fd, vol, inputvol)) < 0) /* createRawFile already reported the exact error. */ ret = -1; -@@ -712,6 +730,7 @@ virStorageBackendCreateQemuImgOpts(char +@@ -717,6 +735,7 @@ virStorageBackendCreateQemuImgOpts(char bool preallocate, int format, const char *compat, @@ -84,7 +82,7 @@ Index: libvirt-1.2.3/src/storage/storage_backend.c virBitmapPtr features) { virBuffer buf = VIR_BUFFER_INITIALIZER; -@@ -724,6 +743,8 @@ virStorageBackendCreateQemuImgOpts(char +@@ -729,6 +748,8 @@ virStorageBackendCreateQemuImgOpts(char virBufferAddLit(&buf, "encryption=on,"); if (preallocate) virBufferAddLit(&buf, "preallocation=metadata,"); @@ -93,7 +91,7 @@ Index: libvirt-1.2.3/src/storage/storage_backend.c if (compat) virBufferAsprintf(&buf, "compat=%s,", compat); -@@ -945,6 +966,7 @@ virStorageBackendCreateQemuImgCmd(virCon +@@ -950,6 +971,7 @@ virStorageBackendCreateQemuImgCmd(virCon do_encryption, preallocate, vol->target.format, compat, @@ -101,3 +99,15 @@ Index: libvirt-1.2.3/src/storage/storage_backend.c vol->target.features) < 0) { virCommandFree(cmd); return NULL; +Index: libvirt-1.2.4/src/util/virstoragefile.h +=================================================================== +--- libvirt-1.2.4.orig/src/util/virstoragefile.h ++++ libvirt-1.2.4/src/util/virstoragefile.h +@@ -228,6 +228,7 @@ struct _virStorageSource { + int format; /* enum virStorageFileFormat */ + virBitmapPtr features; + char *compat; ++ bool nocow; + + virStoragePermsPtr perms; + virStorageTimestampsPtr timestamps; diff --git a/libvirt.spec b/libvirt.spec index 617f242..1d246d5 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -436,7 +436,7 @@ Patch3: d6b27d3e-CVE-2014-0179.patch Patch100: xen-name-for-devid.patch Patch101: ia64-clone.patch Patch102: xen-pv-cdrom.patch -#Patch103: add-nocow-to-vol-xml.patch +Patch103: add-nocow-to-vol-xml.patch # pending review upstream patches Patch150: libxl-migration-support.patch # Our patches @@ -957,7 +957,7 @@ namespaces. %patch100 -p1 %patch101 -p1 %patch102 -p1 -#%patch103 -p1 +%patch103 -p1 %patch150 -p1 %patch200 -p1 %patch201 -p1