From 3da5a7017eaeb50858512d8a1de673d7355dd69a004c743459efd98639f004c6 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Tue, 18 Oct 2011 21:25:37 +0000 Subject: [PATCH] libvirt updates for openSUSE12.1 OBS-URL: https://build.opensuse.org/package/show/Virtualization/libvirt?expand=0&rev=166 --- c1bc3d89-qemu-add-ahci.patch | 244 +++++++++++++++++++++++++++++++++++ libvirt.changes | 9 ++ libvirt.spec | 10 +- suse-qemu-conf.patch | 21 +++ 4 files changed, 281 insertions(+), 3 deletions(-) create mode 100644 c1bc3d89-qemu-add-ahci.patch create mode 100644 suse-qemu-conf.patch diff --git a/c1bc3d89-qemu-add-ahci.patch b/c1bc3d89-qemu-add-ahci.patch new file mode 100644 index 0000000..574f7c8 --- /dev/null +++ b/c1bc3d89-qemu-add-ahci.patch @@ -0,0 +1,244 @@ +commit c1bc3d892c7388ad5c7c70a298107236717a009a +Author: Jim Fehlig +Date: Tue Sep 27 21:46:08 2011 -0600 + + Add AHCI support to qemu driver + + Tested with multiple AHCI controllers and multiple disks attached + to a controller. E.g., + + + + + +
+ + + + + +
+ + + + + +
+ + +
+ + +
+ + +Index: libvirt-0.9.6/docs/formatdomain.html.in +=================================================================== +--- libvirt-0.9.6.orig/docs/formatdomain.html.in ++++ libvirt-0.9.6/docs/formatdomain.html.in +@@ -972,11 +972,12 @@ + as a device ordering hint. The optional bus + attribute specifies the type of disk device to emulate; + possible values are driver specific, with typical values being +- "ide", "scsi", "virtio", "xen" or "usb". If omitted, the bus type is +- inferred from the style of the device name. eg, a device named 'sda' +- will typically be exported using a SCSI bus. ++ "ide", "scsi", "virtio", "xen", "usb" or "sata". If omitted, the bus ++ type is inferred from the style of the device name. eg, a device named ++ 'sda' will typically be exported using a SCSI bus. + Since 0.0.3; bus attribute since 0.4.3; +- "usb" attribute value since after 0.4.4 ++ "usb" attribute value since after 0.4.4; "sata" attribute value since ++ 0.9.7 +
driver
+
+ The optional driver element allows specifying further details +Index: libvirt-0.9.6/docs/schemas/domaincommon.rng +=================================================================== +--- libvirt-0.9.6.orig/docs/schemas/domaincommon.rng ++++ libvirt-0.9.6/docs/schemas/domaincommon.rng +@@ -790,6 +790,7 @@ + xen + usb + uml ++ sata + + + +Index: libvirt-0.9.6/src/conf/domain_conf.c +=================================================================== +--- libvirt-0.9.6.orig/src/conf/domain_conf.c ++++ libvirt-0.9.6/src/conf/domain_conf.c +@@ -2156,6 +2156,15 @@ virDomainDiskDefAssignAddress(virCapsPtr + def->info.addr.drive.unit = (idx % 2); + break; + ++ case VIR_DOMAIN_DISK_BUS_SATA: ++ /* For SATA we define the default mapping to be 6 units ++ * per bus, 1 bus per controller, many controllers */ ++ def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; ++ def->info.addr.drive.controller = idx / 6; ++ def->info.addr.drive.bus = 0; ++ def->info.addr.drive.unit = idx % 6; ++ break; ++ + case VIR_DOMAIN_DISK_BUS_FDC: + /* For FDC we define the default mapping to be 2 units + * per bus, 1 bus per controller, many controllers */ +@@ -8674,6 +8683,11 @@ int virDomainDefAddImplicitControllers(v + VIR_DOMAIN_DISK_BUS_IDE) < 0) + return -1; + ++ if (virDomainDefAddDiskControllersForType(def, ++ VIR_DOMAIN_CONTROLLER_TYPE_SATA, ++ VIR_DOMAIN_DISK_BUS_SATA) < 0) ++ return -1; ++ + if (virDomainDefMaybeAddVirtioSerialController(def) < 0) + return -1; + +Index: libvirt-0.9.6/src/qemu/qemu_capabilities.c +=================================================================== +--- libvirt-0.9.6.orig/src/qemu/qemu_capabilities.c ++++ libvirt-0.9.6/src/qemu/qemu_capabilities.c +@@ -136,6 +136,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST, + "pci-ohci", + "usb-redir", + "usb-hub", ++ "ich9-ahci", + ); + + struct qemu_feature_flags { +@@ -1227,6 +1228,8 @@ qemuCapsParseDeviceStr(const char *str, + qemuCapsSet(flags, QEMU_CAPS_USB_REDIR); + if (strstr(str, "name \"usb-hub\"")) + qemuCapsSet(flags, QEMU_CAPS_USB_HUB); ++ if (strstr(str, "name \"ich9-ahci\"")) ++ qemuCapsSet(flags, QEMU_CAPS_ICH9_AHCI); + + /* Prefer -chardev spicevmc (detected earlier) over -device spicevmc */ + if (!qemuCapsGet(flags, QEMU_CAPS_CHARDEV_SPICEVMC) && +Index: libvirt-0.9.6/src/qemu/qemu_capabilities.h +=================================================================== +--- libvirt-0.9.6.orig/src/qemu/qemu_capabilities.h ++++ libvirt-0.9.6/src/qemu/qemu_capabilities.h +@@ -110,6 +110,7 @@ enum qemuCapsFlags { + QEMU_CAPS_PCI_OHCI = 71, /* -device pci-ohci */ + QEMU_CAPS_USB_REDIR = 72, /* -device usb-redir */ + QEMU_CAPS_USB_HUB = 73, /* -device usb-hub */ ++ QEMU_CAPS_ICH9_AHCI = 74, /* -device ich9-ahci */ + + QEMU_CAPS_LAST, /* this must always be the last item */ + }; +Index: libvirt-0.9.6/src/qemu/qemu_command.c +=================================================================== +--- libvirt-0.9.6.orig/src/qemu/qemu_command.c ++++ libvirt-0.9.6/src/qemu/qemu_command.c +@@ -1694,6 +1694,12 @@ qemuBuildDriveDevStr(virDomainDiskDefPtr + disk->info.addr.drive.bus, + disk->info.addr.drive.unit); + break; ++ case VIR_DOMAIN_DISK_BUS_SATA: ++ virBufferAddLit(&opt, "ide-drive"); ++ virBufferAsprintf(&opt, ",bus=ahci%d.%d", ++ disk->info.addr.drive.controller, ++ disk->info.addr.drive.unit); ++ break; + case VIR_DOMAIN_DISK_BUS_VIRTIO: + virBufferAddLit(&opt, "virtio-blk-pci"); + qemuBuildIoEventFdStr(&opt, disk->ioeventfd, qemuCaps); +@@ -1894,6 +1900,10 @@ qemuBuildControllerDevStr(virDomainContr + virBufferAsprintf(&buf, "usb-ccid,id=ccid%d", def->idx); + break; + ++ case VIR_DOMAIN_CONTROLLER_TYPE_SATA: ++ virBufferAsprintf(&buf, "ahci,id=ahci%d", def->idx); ++ break; ++ + case VIR_DOMAIN_CONTROLLER_TYPE_USB: + if (qemuBuildUSBControllerDevStr(def, qemuCaps, &buf) == -1) + goto error; +@@ -3675,14 +3685,22 @@ qemuBuildCommandLine(virConnectPtr conn, + cont->type == VIR_DOMAIN_CONTROLLER_TYPE_FDC) + continue; + +- /* QEMU doesn't implement a SATA driver */ ++ /* Only recent QEMU implements a SATA (AHCI) controller */ + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) { +- qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- "%s", _("SATA is not supported with this QEMU binary")); +- goto error; +- } ++ if (!qemuCapsGet(qemuCaps, QEMU_CAPS_ICH9_AHCI)) { ++ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ "%s", _("SATA is not supported with this QEMU binary")); ++ goto error; ++ } else { ++ char *devstr; ++ ++ virCommandAddArg(cmd, "-device"); ++ if (!(devstr = qemuBuildControllerDevStr(cont, qemuCaps, NULL))) ++ goto error; + +- if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && ++ virCommandAddArg(cmd, devstr); ++ } ++ } else if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB && + def->controllers[i]->model == -1 && + !qemuCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) { + if (usblegacy) { +Index: libvirt-0.9.6/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.args +=================================================================== +--- /dev/null ++++ libvirt-0.9.6/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.args +@@ -0,0 +1,6 @@ ++LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu -S -M \ ++pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults -monitor \ ++unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device ahci,id=ahci0,\ ++bus=pci.0,addr=0x3 -drive file=/dev/HostVG/QEMUGuest1,if=none,\ ++id=drive-sata0-0-0 -device ide-drive,bus=ahci0.0,drive=drive-sata0-0-0,\ ++id=sata0-0-0 -usb -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4 +Index: libvirt-0.9.6/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.xml +=================================================================== +--- /dev/null ++++ libvirt-0.9.6/tests/qemuxml2argvdata/qemuxml2argv-disk-sata-device.xml +@@ -0,0 +1,25 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219136 ++ 219136 ++ 1 ++ ++ hvm ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu ++ ++ ++ ++
++ ++ ++ ++ ++ +Index: libvirt-0.9.6/tests/qemuxml2argvtest.c +=================================================================== +--- libvirt-0.9.6.orig/tests/qemuxml2argvtest.c ++++ libvirt-0.9.6/tests/qemuxml2argvtest.c +@@ -356,6 +356,9 @@ mymain(void) + QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); + DO_TEST("disk-scsi-device-auto", false, + QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG); ++ DO_TEST("disk-sata-device", false, ++ QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, ++ QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_ICH9_AHCI); + DO_TEST("disk-aio", false, + QEMU_CAPS_DRIVE, QEMU_CAPS_DRIVE_AIO, + QEMU_CAPS_DRIVE_CACHE_V2, QEMU_CAPS_DRIVE_FORMAT); diff --git a/libvirt.changes b/libvirt.changes index df34e7f..46ce41f 100644 --- a/libvirt.changes +++ b/libvirt.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Tue Oct 18 15:20:11 MDT 2011 - jfehlig@suse.com + +- Add AHCI controller support to qemu driver + c1bc3d89-qemu-add-ahci.patch +- Set security driver to 'none' in /etc/libvirt/qemu.conf. Users + must opt-in for Apparmor confinement of qemu instances. + suse-qemu-conf.patch + ------------------------------------------------------------------- Thu Sep 22 21:08:11 MDT 2011 - jfehlig@suse.com diff --git a/libvirt.spec b/libvirt.spec index 0f6ee28..b1fe853 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -374,6 +374,10 @@ Source1: libvirtd.init Source2: libvirtd-relocation-server.fw Source99: baselibs.conf # Upstream patches +# This patch reverts commit f84aedad, which is not needed since +# the openSUSE kvm package is patched with qemu 'no-shutdown' fix +Patch0: f84aedad-revert.patch +Patch1: c1bc3d89-qemu-add-ahci.patch # Need to go upstream Patch100: xen-name-for-devid.patch Patch101: clone.patch @@ -382,9 +386,7 @@ Patch103: xend-disk-order.patch # Our patches Patch200: libvirtd-defaults.patch Patch201: use-init-script-redhat.patch -# This patch reverts commit f84aedad, which is not needed since -# affected SUSE kvm packages have the necessary qemu fix. -Patch202: f84aedad-revert.patch +Patch202: suse-qemu-conf.patch %if %{with_apparmor} Patch250: install-apparmor-profiles.patch %endif @@ -499,6 +501,8 @@ Authors: %prep %setup -q +%patch0 -p1 +%patch1 -p1 %patch100 -p1 %patch101 %patch102 -p1 diff --git a/suse-qemu-conf.patch b/suse-qemu-conf.patch new file mode 100644 index 0000000..6eada67 --- /dev/null +++ b/suse-qemu-conf.patch @@ -0,0 +1,21 @@ +Index: libvirt-0.9.6/src/qemu/qemu.conf +=================================================================== +--- libvirt-0.9.6.orig/src/qemu/qemu.conf ++++ libvirt-0.9.6/src/qemu/qemu.conf +@@ -136,7 +136,16 @@ + # leaving SELinux enabled for the host in general, then set this + # to 'none' instead. + # ++# SUSE Note: ++# Currently, Apparmor is the default security framework in SUSE ++# distros. If Apparmor is enabled on the host, libvirtd is ++# generously confined but users must opt-in to confine qemu ++# instances. Change this to 'apparmor' to enable Apparmor ++# confinement of qemu instances. ++# + # security_driver = "selinux" ++# security_driver = "apparmor" ++security_driver = "none" + + + # The user ID for QEMU processes run by the system instance.