[virt-tools-list] [python-virtinst][PATCH] Don't overwrite target element for disks that have it already set

Guido Günther agx at sigxcpu.org
Wed Sep 19 18:56:34 UTC 2012


This makes the usage consistent with the bus element just above and
allows to setup the target device before adding it to the Installer.
---
I've attached the changed test output as well. As far as I can see this
results from cases where we explicitly set a disk element which gets
overridden. Is this in any way desired behavior?
Cheers,
 -- Guido

 tests/cli-test-xml/compare/image-boot0.xml       |    2 +-
 tests/cli-test-xml/compare/image-nogfx.xml       |    2 +-
 tests/image-xml/image2guest/image-format-out.xml |    2 +-
 virtinst/Guest.py                                |    5 ++++-
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/tests/cli-test-xml/compare/image-boot0.xml b/tests/cli-test-xml/compare/image-boot0.xml
index 0c9b426..ac4ce01 100644
--- a/tests/cli-test-xml/compare/image-boot0.xml
+++ b/tests/cli-test-xml/compare/image-boot0.xml
@@ -18,7 +18,7 @@
     </disk>
     <disk type='file' device='disk'>
       <source file='/tmp/__virtinst__cli_scratch.raw'/>
-      <target dev='xvdb' bus='xen'/>
+      <target dev='xvdc' bus='xen'/>
     </disk>
     <interface type='user'>
       <mac address='00:11:22:33:44:55'/>
diff --git a/tests/cli-test-xml/compare/image-nogfx.xml b/tests/cli-test-xml/compare/image-nogfx.xml
index a7efb38..6f63242 100644
--- a/tests/cli-test-xml/compare/image-nogfx.xml
+++ b/tests/cli-test-xml/compare/image-nogfx.xml
@@ -18,7 +18,7 @@
     </disk>
     <disk type='file' device='disk'>
       <source file='/tmp/__virtinst__cli_scratch.raw'/>
-      <target dev='xvdb' bus='xen'/>
+      <target dev='xvdc' bus='xen'/>
     </disk>
     <interface type='user'>
       <mac address='00:11:22:33:44:55'/>
diff --git a/tests/image-xml/image2guest/image-format-out.xml b/tests/image-xml/image2guest/image-format-out.xml
index 396bbc4..16bc30c 100644
--- a/tests/image-xml/image2guest/image-format-out.xml
+++ b/tests/image-xml/image2guest/image-format-out.xml
@@ -30,7 +30,7 @@
     <disk type='file' device='disk'>
       <driver name='qemu' type='vmdk'/>
       <source file='REPLACEME/tests/image-xml/image-format.xml'/>
-      <target dev='hdd' bus='ide'/>
+      <target dev='hdc' bus='ide'/>
     </disk>
     <input type='mouse' bus='ps2'/>
     <graphics type='sdl' display=':3.4' xauth='/tmp/.Xauthority'/>
diff --git a/virtinst/Guest.py b/virtinst/Guest.py
index 22eac45..54a21ea 100644
--- a/virtinst/Guest.py
+++ b/virtinst/Guest.py
@@ -1513,7 +1513,10 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
                             disk.bus = "ide"
                     elif self.installer.is_xenpv():
                         disk.bus = "xen"
-            used_targets.append(disk.generate_target(used_targets))
+            if disk.target:
+                used_targets.append(disk.target)
+            else:
+                used_targets.append(disk.generate_target(used_targets))
 
         # Set sound device model
         sound_model  = self._lookup_device_param(soundtype, "model")
-- 
1.7.10.4




More information about the virt-tools-list mailing list