mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-12 15:52:55 +00:00
qemu: monitor: Extract the top level format node when querying disks
To allow matching the node names gathered via 'query-named-block-nodes' we need to query and then use the top level nodes from 'query-block'. Add the data to the structure returned by qemuMonitorGetBlockInfo.
This commit is contained in:
parent
b0aa088fad
commit
2780bcd9f8
@ -364,6 +364,7 @@ struct qemuDomainDiskInfo {
|
|||||||
bool tray_open;
|
bool tray_open;
|
||||||
bool empty;
|
bool empty;
|
||||||
int io_status;
|
int io_status;
|
||||||
|
char *nodename;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _qemuDomainHostdevPrivate qemuDomainHostdevPrivate;
|
typedef struct _qemuDomainHostdevPrivate qemuDomainHostdevPrivate;
|
||||||
|
@ -2173,6 +2173,16 @@ qemuMonitorBlockIOStatusToError(const char *status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
qemuDomainDiskInfoFree(void *value, const void *name ATTRIBUTE_UNUSED)
|
||||||
|
{
|
||||||
|
struct qemuDomainDiskInfo *info = value;
|
||||||
|
|
||||||
|
VIR_FREE(info->nodename);
|
||||||
|
VIR_FREE(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virHashTablePtr
|
virHashTablePtr
|
||||||
qemuMonitorGetBlockInfo(qemuMonitorPtr mon)
|
qemuMonitorGetBlockInfo(qemuMonitorPtr mon)
|
||||||
{
|
{
|
||||||
@ -2181,7 +2191,7 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon)
|
|||||||
|
|
||||||
QEMU_CHECK_MONITOR_NULL(mon);
|
QEMU_CHECK_MONITOR_NULL(mon);
|
||||||
|
|
||||||
if (!(table = virHashCreate(32, virHashValueFree)))
|
if (!(table = virHashCreate(32, qemuDomainDiskInfoFree)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
|
@ -1868,9 +1868,11 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
|
|||||||
|
|
||||||
for (i = 0; i < virJSONValueArraySize(devices); i++) {
|
for (i = 0; i < virJSONValueArraySize(devices); i++) {
|
||||||
virJSONValuePtr dev;
|
virJSONValuePtr dev;
|
||||||
|
virJSONValuePtr image;
|
||||||
struct qemuDomainDiskInfo *info;
|
struct qemuDomainDiskInfo *info;
|
||||||
const char *thisdev;
|
const char *thisdev;
|
||||||
const char *status;
|
const char *status;
|
||||||
|
const char *nodename;
|
||||||
|
|
||||||
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
|
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1907,8 +1909,12 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
|
|||||||
info->tray = true;
|
info->tray = true;
|
||||||
|
|
||||||
/* presence of 'inserted' notifies that a medium is in the device */
|
/* presence of 'inserted' notifies that a medium is in the device */
|
||||||
if (!virJSONValueObjectGetObject(dev, "inserted"))
|
if ((image = virJSONValueObjectGetObject(dev, "inserted"))) {
|
||||||
|
if ((nodename = virJSONValueObjectGetString(image, "node-name")))
|
||||||
|
ignore_value(VIR_STRDUP(info->nodename, nodename));
|
||||||
|
} else {
|
||||||
info->empty = true;
|
info->empty = true;
|
||||||
|
}
|
||||||
|
|
||||||
/* Missing io-status indicates no error */
|
/* Missing io-status indicates no error */
|
||||||
if ((status = virJSONValueObjectGetString(dev, "io-status"))) {
|
if ((status = virJSONValueObjectGetString(dev, "io-status"))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user