提交 c03e52af 编写于 作者: P Peter Krempa

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: NEric Blake <eblake@redhat.com>
上级 acfd2fdc
...@@ -56,6 +56,9 @@ qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data) ...@@ -56,6 +56,9 @@ qemuBlockNodeNameBackingChainDataFree(qemuBlockNodeNameBackingChainDataPtr data)
VIR_FREE(data->qemufilename); VIR_FREE(data->qemufilename);
VIR_FREE(data->drvformat);
VIR_FREE(data->drvstorage);
qemuBlockNodeNameBackingChainDataFree(data->backing); qemuBlockNodeNameBackingChainDataFree(data->backing);
VIR_FREE(data); VIR_FREE(data);
...@@ -108,7 +111,8 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next, ...@@ -108,7 +111,8 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
virJSONValuePtr parentnodedata; virJSONValuePtr parentnodedata;
virJSONValuePtr nodedata; virJSONValuePtr nodedata;
const char *nodename = virJSONValueObjectGetString(next, "node-name"); const char *nodename = virJSONValueObjectGetString(next, "node-name");
const char *drvname; const char *drvname = NULL;
const char *drvparent = NULL;
const char *parentnodename = NULL; const char *parentnodename = NULL;
const char *filename = NULL; const char *filename = NULL;
int ret = -1; int ret = -1;
...@@ -134,8 +138,10 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next, ...@@ -134,8 +138,10 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
if (parent && if (parent &&
(parentnodename = virJSONValueObjectGetString(parent, "node-name"))) { (parentnodename = virJSONValueObjectGetString(parent, "node-name"))) {
if ((parentnodedata = virHashLookup(nodenamestable, parentnodename))) if ((parentnodedata = virHashLookup(nodenamestable, parentnodename))) {
filename = virJSONValueObjectGetString(parentnodedata, "file"); filename = virJSONValueObjectGetString(parentnodedata, "file");
drvparent = virJSONValueObjectGetString(parentnodedata, "drv");
}
} }
if (VIR_ALLOC(data) < 0) if (VIR_ALLOC(data) < 0)
...@@ -143,7 +149,9 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next, ...@@ -143,7 +149,9 @@ qemuBlockNodeNameGetBackingChainBacking(virJSONValuePtr next,
if (VIR_STRDUP(data->nodeformat, nodename) < 0 || if (VIR_STRDUP(data->nodeformat, nodename) < 0 ||
VIR_STRDUP(data->nodestorage, parentnodename) < 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; goto cleanup;
if (backing && if (backing &&
......
...@@ -35,6 +35,10 @@ struct qemuBlockNodeNameBackingChainData { ...@@ -35,6 +35,10 @@ struct qemuBlockNodeNameBackingChainData {
char *nodestorage; /* node name of the storage backing the format node */ char *nodestorage; /* node name of the storage backing the format node */
qemuBlockNodeNameBackingChainDataPtr backing; qemuBlockNodeNameBackingChainDataPtr backing;
/* for testing purposes */
char *drvformat;
char *drvstorage;
}; };
virHashTablePtr virHashTablePtr
......
drive-virtio-disk0 drive-virtio-disk0
filename : '/var/lib/libvirt/images/rhel7.3.1483545313' filename : '/var/lib/libvirt/images/rhel7.3.1483545313'
format node : '#block187' format node : '#block187'
format drv : 'qcow2'
storage node: '#block033' storage node: '#block033'
storage drv : 'file'
filename : '/var/lib/libvirt/images/rhel7.3.1483536402' filename : '/var/lib/libvirt/images/rhel7.3.1483536402'
format node : '#block306' format node : '#block306'
format drv : 'qcow2'
storage node: '#block220' storage node: '#block220'
storage drv : 'file'
filename : '/var/lib/libvirt/images/rhel7.3.qcow2' filename : '/var/lib/libvirt/images/rhel7.3.qcow2'
format node : '#block558' format node : '#block558'
format drv : 'qcow2'
storage node: '#block481' storage node: '#block481'
storage drv : 'file'
...@@ -2714,8 +2714,10 @@ testBlockNodeNameDetectFormat(void *payload, ...@@ -2714,8 +2714,10 @@ testBlockNodeNameDetectFormat(void *payload,
virBufferAsprintf(buf, "filename : '%s'\n", entry->qemufilename); virBufferAsprintf(buf, "filename : '%s'\n", entry->qemufilename);
virBufferAsprintf(buf, "format node : '%s'\n", virBufferAsprintf(buf, "format node : '%s'\n",
NULLSTR(entry->nodeformat)); NULLSTR(entry->nodeformat));
virBufferAsprintf(buf, "format drv : '%s'\n", NULLSTR(entry->drvformat));
virBufferAsprintf(buf, "storage node: '%s'\n", virBufferAsprintf(buf, "storage node: '%s'\n",
NULLSTR(entry->nodestorage)); NULLSTR(entry->nodestorage));
virBufferAsprintf(buf, "storage drv : '%s'\n", NULLSTR(entry->drvstorage));
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册