]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: check driver name while attaching disk
authorWen Congyang <wency@cn.fujitsu.com>
Mon, 7 Mar 2011 06:35:49 +0000 (14:35 +0800)
committerLaine Stump <laine@laine.org>
Fri, 18 Mar 2011 04:36:37 +0000 (00:36 -0400)
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 <wency@cn.fujitsu.com>
src/qemu/qemu_driver.c

index 6055d8072bb5e6518ed51ea099ac4744cdf9f1ea..076177cde009c4693a851f1d71c7d90852c74f18 100644 (file)
@@ -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,