From e2aec53b9706bc2872cb1ce6d0ceecceda762649 Mon Sep 17 00:00:00 2001 From: Wen Congyang Date: Mon, 7 Mar 2011 14:35:49 +0800 Subject: [PATCH] qemu: check driver name while attaching disk This bug was reported by Shi Jin(jinzishuai@gmail.com): ============= # virsh attach-disk RHEL6RC /var/lib/libvirt/images/test3.img vdb \ --driver file --subdriver qcow2 Disk attached successfully # virsh save RHEL6RC /var/lib/libvirt/images/memory.save Domain RHEL6RC saved to /var/lib/libvirt/images/memory.save # virsh restore /var/lib/libvirt/images/memory.save error: Failed to restore domain from /var/lib/libvirt/images/memory.save error: internal error unsupported driver name 'file' for disk '/var/lib/libvirt/images/test3.img' ============= We check the driver name when we start or restore VM, but we do not check it while attaching a disk. This adds the same check on disk driverName used in qemuBuildCommandLine to qemudDomainAttachDevice. Signed-off-by: Wen Congyang --- src/qemu/qemu_driver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6055d8072b..076177cde0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4025,6 +4025,14 @@ static int qemudDomainAttachDevice(virDomainPtr dom, goto endjob; if (dev->type == VIR_DOMAIN_DEVICE_DISK) { + if (dev->data.disk->driverName != NULL && + !STREQ(dev->data.disk->driverName, "qemu")) { + qemuReportError(VIR_ERR_INTERNAL_ERROR, + _("unsupported driver name '%s' for disk '%s'"), + dev->data.disk->driverName, dev->data.disk->src); + goto endjob; + } + if (qemuCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_DEVICES)) { if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) !=0 ) { qemuReportError(VIR_ERR_INTERNAL_ERROR,