mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
virsh: Correctly detect inserted media in change-media command
https://bugzilla.redhat.com/show_bug.cgi?id=1250331 It all works like this. The change-media command dumps domain XML, finds the corresponding cdrom device we want to change media in and returns it in the xmlNodePtr form. This way we don't have to bother with keeping all the subelements or attributes that we don't care about in the XML that is fed back to libvirt for the update API. Now, the problem is we try to be clever here and detect if disk already has a source (indicated by <source/> subelement). However, bare fact that the element is there does not mean disk has source. Make our clever check better. Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
35c3aab44d
commit
9cbd1ecc3e
@ -11055,6 +11055,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
|
||||
char *device_type = NULL;
|
||||
char *ret = NULL;
|
||||
char *startupPolicy = NULL;
|
||||
char *source_path = NULL;
|
||||
|
||||
if (!disk_node)
|
||||
return NULL;
|
||||
@ -11111,7 +11112,13 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
|
||||
}
|
||||
|
||||
if (source) {
|
||||
if (type == VIRSH_UPDATE_DISK_XML_INSERT) {
|
||||
if (!(source_path = virXMLPropString(source, "file")) &&
|
||||
!(source_path = virXMLPropString(source, "dev")) &&
|
||||
!(source_path = virXMLPropString(source, "dir")) &&
|
||||
!(source_path = virXMLPropString(source, "pool")))
|
||||
source_path = virXMLPropString(source, "name");
|
||||
|
||||
if (source_path && type == VIRSH_UPDATE_DISK_XML_INSERT) {
|
||||
vshError(NULL, _("The disk device '%s' already has media"), target);
|
||||
goto cleanup;
|
||||
}
|
||||
@ -11170,6 +11177,7 @@ virshUpdateDiskXML(xmlNodePtr disk_node,
|
||||
cleanup:
|
||||
VIR_FREE(device_type);
|
||||
VIR_FREE(startupPolicy);
|
||||
VIR_FREE(source_path);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user