[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH v5.1 08/11] virCaps: get rid of defaultDiskDriverType



Use the qemu specific callback to fill this data in the qemu driver as
it's the only place where it was used and fix tests as the qemu test
capability object didn't configure the defaults for the tests.
---
 src/conf/capabilities.h                            |  1 -
 src/conf/domain_conf.c                             |  5 ---
 src/qemu/qemu_conf.c                               |  6 ----
 src/qemu/qemu_domain.c                             | 42 ++++++++++++++++++----
 ...qemuxml2argv-disk-drive-network-nbd-export.args |  3 +-
 .../qemuxml2argv-disk-drive-network-nbd-export.xml |  1 +
 ...ml2argv-disk-drive-network-nbd-ipv6-export.args |  3 +-
 ...xml2argv-disk-drive-network-nbd-ipv6-export.xml |  1 +
 .../qemuxml2argv-disk-drive-network-nbd-ipv6.args  |  3 +-
 .../qemuxml2argv-disk-drive-network-nbd-ipv6.xml   |  1 +
 .../qemuxml2argv-disk-drive-network-nbd-unix.args  |  3 +-
 .../qemuxml2argv-disk-drive-network-nbd-unix.xml   |  1 +
 .../qemuxml2argv-disk-drive-network-nbd.args       |  5 +--
 .../qemuxml2argv-disk-drive-network-nbd.xml        |  1 +
 .../qemuxml2argv-disk-drive-network-rbd-auth.args  |  2 +-
 .../qemuxml2argv-disk-drive-network-rbd-ipv6.args  |  2 +-
 .../qemuxml2argv-disk-drive-network-rbd-ipv6.xml   |  1 +
 .../qemuxml2argv-disk-drive-network-rbd.args       |  2 +-
 .../qemuxml2argv-disk-drive-network-rbd.xml        |  1 +
 .../qemuxml2argv-disk-drive-network-sheepdog.args  |  3 +-
 .../qemuxml2argv-disk-drive-network-sheepdog.xml   |  1 +
 21 files changed, 59 insertions(+), 29 deletions(-)

diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h
index 5e7a5f6..743b1f0 100644
--- a/src/conf/capabilities.h
+++ b/src/conf/capabilities.h
@@ -163,7 +163,6 @@ struct _virCaps {

     /* Move to virDomainXMLOption later */
     unsigned char macPrefix[VIR_MAC_PREFIX_BUFLEN];
-    int defaultDiskDriverType; /* enum virStorageFileFormat */
     int (*defaultConsoleTargetType)(const char *ostype, virArch guestarch);
     bool hasWideScsiBus;
 };
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6a480d0..ab4227e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4824,9 +4824,6 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                            driverType);
             goto error;
         }
-    } else if (def->type == VIR_DOMAIN_DISK_TYPE_FILE ||
-               def->type == VIR_DOMAIN_DISK_TYPE_BLOCK) {
-        def->format = caps->defaultDiskDriverType;
     }

     if (mirrorFormat) {
@@ -4837,8 +4834,6 @@ virDomainDiskDefParseXML(virCapsPtr caps,
                            driverType);
             goto error;
         }
-    } else if (def->mirror) {
-        def->mirrorFormat = caps->defaultDiskDriverType;
     }

     if (def->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 268223f..084b694 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -574,12 +574,6 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)
     if (!(caps = virQEMUCapsInit(driver->qemuCapsCache)))
         goto no_memory;

-    if (cfg->allowDiskFormatProbing) {
-        caps->defaultDiskDriverType = VIR_STORAGE_FILE_AUTO;
-    } else {
-        caps->defaultDiskDriverType = VIR_STORAGE_FILE_RAW;
-    }
-
     if (virGetHostUUID(caps->host.host_uuid)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        "%s", _("cannot get the host uuid"));
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 3073257..e5e9223 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -693,13 +693,41 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
                 goto no_memory;
     }

-    if (dev->type == VIR_DOMAIN_DEVICE_DISK &&
-        !dev->data.disk->driverName &&
-        driver &&
-        (cfg = virQEMUDriverGetConfig(driver))) {
-        if (!cfg->allowDiskFormatProbing &&
-            !(dev->data.disk->driverName = strdup("qemu"))) {
-            goto no_memory;
+    /* set default disk types and drivers */
+    if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
+        virDomainDiskDefPtr disk = dev->data.disk;
+
+        /* both of these require data from the driver config */
+        if (driver && (cfg = virQEMUDriverGetConfig(driver))) {
+            /* assign default storage format and driver according to config */
+            if (cfg->allowDiskFormatProbing) {
+                /* default disk format for drives */
+                if (disk->format == VIR_STORAGE_FILE_NONE &&
+                    (disk->type == VIR_DOMAIN_DISK_TYPE_FILE ||
+                     disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK))
+                    disk->format = VIR_STORAGE_FILE_AUTO;
+
+                 /* default disk format for mirrored drive */
+                if (disk->mirror &&
+                    disk->mirrorFormat == VIR_STORAGE_FILE_NONE)
+                    disk->mirrorFormat = VIR_STORAGE_FILE_AUTO;
+            } else {
+                /* default driver if probing is forbidden */
+                if (!disk->driverName &&
+                    !(disk->driverName = strdup("qemu")))
+                        goto no_memory;
+
+                /* default disk format for drives */
+                if (disk->format == VIR_STORAGE_FILE_NONE &&
+                    (disk->type == VIR_DOMAIN_DISK_TYPE_FILE ||
+                     disk->type == VIR_DOMAIN_DISK_TYPE_BLOCK))
+                    disk->format = VIR_STORAGE_FILE_RAW;
+
+                 /* default disk format for mirrored drive */
+                if (disk->mirror &&
+                    disk->mirrorFormat == VIR_STORAGE_FILE_NONE)
+                    disk->mirrorFormat = VIR_STORAGE_FILE_RAW;
+            }
         }
     }

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args
index bc9d93d..ca70ce4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.args
@@ -1,5 +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 -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \
+-no-acpi -boot c -usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \
 -drive file=nbd:example.org:6000:exportname=bar,if=virtio,format=raw \
 -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml
index f2b5ca4..7a84604 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-export.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args
index 1541073..745efe7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.args
@@ -1,5 +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 -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \
+-no-acpi -boot c -usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \
 -drive 'file=nbd://[::1]:6000/bar,if=virtio,format=raw' -net none \
 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml
index 595d7ea..c063db8 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6-export.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args
index a28d015..0331ff5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.args
@@ -1,5 +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 -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \
+-no-acpi -boot c -usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \
 -drive 'file=nbd://[::1]:6000,if=virtio,format=raw' -net none \
 -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml
index 3c5c99d..540aa02 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-ipv6.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args
index 977b68f..84cae4a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.args
@@ -1,5 +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 -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 \
+-no-acpi -boot c -usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \
 -drive file=nbd:unix:/var/run/nbdsock:exportname=bar,if=virtio,format=raw \
 -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml
index 46114d5..a4126f5 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd-unix.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args
index 856217b..8d0f69f 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.args
@@ -1,5 +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 -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -usb -drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \
-file=nbd:example.org:6000,if=virtio,format=raw -net none -serial none \
+-no-acpi -boot c -usb \
+-drive file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw \
+-drive file=nbd:example.org:6000,if=virtio,format=raw -net none -serial none \
 -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml
index e31da87..36301a9 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-nbd.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args
index 4f3ccd5..6714553 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth.args
@@ -1,7 +1,7 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
 /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor \
 unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \
-file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \
+file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw -drive \
 'file=rbd:pool/image:\
 id=myname:\
 key=QVFDVm41aE82SHpGQWhBQXEwTkN2OGp0SmNJY0UrSE9CbE1RMUE=:\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args
index 0c67229..6623161 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.args
@@ -1,7 +1,7 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
 /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor \
 unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \
-file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \
+file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw -drive \
 'file=rbd:pool/image:auth_supported=none:\
 mon_host=[\:\:1]\:6321\;example.org\:6789\;\
 [ffff\:1234\:567\:abc\:\:0f]\:6322\;\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml
index a2ca2d2..be4edbf 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-ipv6.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args
index ad3ed3e..cf433a3 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.args
@@ -1,7 +1,7 @@
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test \
 /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor \
 unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -usb -drive \
-file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0 -drive \
+file=/dev/HostVG/QEMUGuest1,if=ide,bus=0,unit=0,format=raw -drive \
 'file=rbd:pool/image:auth_supported=none:\
 mon_host=mon1.example.org\:6321\;mon2.example.org\:6322\;\
 mon3.example.org\:6322,\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml
index 8309cae..081f9a6 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args
index 3e9d913..e0a5cfa 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.args
@@ -1,5 +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 -monitor unix:/tmp/test-monitor,server,nowait \
--no-acpi -boot c -usb -drive file=/dev/HostVG/QEMU,,Guest,,,,1,if=ide,bus=0,unit=0 \
+-no-acpi -boot c -usb \
+-drive file=/dev/HostVG/QEMU,,Guest,,,,1,if=ide,bus=0,unit=0,format=raw \
 -drive file=sheepdog:example.org:6000:image,,with,,commas,if=virtio,format=raw \
 -net none -serial none -parallel none
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml
index 7917357..ac89dd7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-sheepdog.xml
@@ -15,6 +15,7 @@
   <devices>
     <emulator>/usr/bin/qemu</emulator>
     <disk type='block' device='disk'>
+      <driver name='qemu' type='raw'/>
       <source dev='/dev/HostVG/QEMU,Guest,,1'/>
       <target dev='hda' bus='ide'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
-- 
1.8.1.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]