]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: fix change-media bug on disk block type
authorGuannan Ren <gren@redhat.com>
Mon, 22 Jul 2013 07:38:43 +0000 (15:38 +0800)
committerGuannan Ren <gren@redhat.com>
Tue, 23 Jul 2013 06:20:56 +0000 (14:20 +0800)
Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=923053
When cdrom is block type, the virsh change-media failed to insert
source info because virsh uses "<source block='/dev/sdb'/>" while
the correct name of the attribute for block disks is "dev".

tools/virsh-domain.c

index 606bcdf6ea4d0d26a1e39be8303cf304e4e0ad75..8cafce4ccc9c268fd8d1aac0b0c5a0f5e3e9dbb7 100644 (file)
@@ -9866,8 +9866,10 @@ vshPrepareDiskXML(xmlNodePtr disk_node,
 
             if (source) {
                 new_node = xmlNewNode(NULL, BAD_CAST "source");
-                xmlNewProp(new_node, (const xmlChar *)disk_type,
-                           (const xmlChar *)source);
+                if (STREQ(disk_type, "block"))
+                    xmlNewProp(new_node, BAD_CAST "dev", BAD_CAST source);
+                else
+                    xmlNewProp(new_node, BAD_CAST disk_type, BAD_CAST source);
                 xmlAddChild(disk_node, new_node);
             } else if (type == VSH_PREPARE_DISK_XML_INSERT) {
                 vshError(NULL, _("No source is specified for inserting media"));