mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
qemu: block: store and test driver names for detected storage nodes
Store the 'drv' field both for the storage node and for the format node and format them in the test case. Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
acfd2fdcbf
commit
c03e52af57
@ -56,6 +56,9 @@ qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data)
|
||||
|
||||
VIR_FREE(data->qemufilename);
|
||||
|
||||
VIR_FREE(data->drvformat);
|
||||
VIR_FREE(data->drvstorage);
|
||||
|
||||
qemuBlockNodeNameBackingChainDataFree(data->backing);
|
||||
|
||||
VIR_FREE(data);
|
||||
@ -108,7 +111,8 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
|
||||
virJSONValuePtr parentnodedata;
|
||||
virJSONValuePtr nodedata;
|
||||
const char *nodename = virJSONValueObjectGetString(next, "node-name");
|
||||
const char *drvname;
|
||||
const char *drvname = NULL;
|
||||
const char *drvparent = NULL;
|
||||
const char *parentnodename = NULL;
|
||||
const char *filename = NULL;
|
||||
int ret = -1;
|
||||
@ -134,8 +138,10 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
|
||||
|
||||
if (parent &&
|
||||
(parentnodename = virJSONValueObjectGetString(parent, "node-name"))) {
|
||||
if ((parentnodedata = virHashLookup(nodenamestable, parentnodename)))
|
||||
if ((parentnodedata = virHashLookup(nodenamestable, parentnodename))) {
|
||||
filename = virJSONValueObjectGetString(parentnodedata, "file");
|
||||
drvparent = virJSONValueObjectGetString(parentnodedata, "drv");
|
||||
}
|
||||
}
|
||||
|
||||
if (VIR_ALLOC(data) < 0)
|
||||
@ -143,7 +149,9 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
|
||||
|
||||
if (VIR_STRDUP(data->nodeformat, nodename) < 0 ||
|
||||
VIR_STRDUP(data->nodestorage, parentnodename) < 0 ||
|
||||
VIR_STRDUP(data->qemufilename, filename) < 0)
|
||||
VIR_STRDUP(data->qemufilename, filename) < 0 ||
|
||||
VIR_STRDUP(data->drvformat, drvname) < 0 ||
|
||||
VIR_STRDUP(data->drvstorage, drvparent) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (backing &&
|
||||
|
@ -35,6 +35,10 @@ struct qemuBlockNodeNameBackingChainData {
|
||||
char *nodestorage; /* node name of the storage backing the format node */
|
||||
|
||||
qemuBlockNodeNameBackingChainDataPtr backing;
|
||||
|
||||
/* for testing purposes */
|
||||
char *drvformat;
|
||||
char *drvstorage;
|
||||
};
|
||||
|
||||
virHashTablePtr
|
||||
|
@ -1,10 +1,16 @@
|
||||
drive-virtio-disk0
|
||||
filename : '/var/lib/libvirt/images/rhel7.3.1483545313'
|
||||
format node : '#block187'
|
||||
format drv : 'qcow2'
|
||||
storage node: '#block033'
|
||||
storage drv : 'file'
|
||||
filename : '/var/lib/libvirt/images/rhel7.3.1483536402'
|
||||
format node : '#block306'
|
||||
format drv : 'qcow2'
|
||||
storage node: '#block220'
|
||||
storage drv : 'file'
|
||||
filename : '/var/lib/libvirt/images/rhel7.3.qcow2'
|
||||
format node : '#block558'
|
||||
format drv : 'qcow2'
|
||||
storage node: '#block481'
|
||||
storage drv : 'file'
|
||||
|
@ -2714,8 +2714,10 @@ testBlockNodeNameDetectFormat(void *payload,
|
||||
virBufferAsprintf(buf, "filename : '%s'\n", entry->qemufilename);
|
||||
virBufferAsprintf(buf, "format node : '%s'\n",
|
||||
NULLSTR(entry->nodeformat));
|
||||
virBufferAsprintf(buf, "format drv : '%s'\n", NULLSTR(entry->drvformat));
|
||||
virBufferAsprintf(buf, "storage node: '%s'\n",
|
||||
NULLSTR(entry->nodestorage));
|
||||
virBufferAsprintf(buf, "storage drv : '%s'\n", NULLSTR(entry->drvstorage));
|
||||
|
||||
virBufferAdjustIndent(buf, 2);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user