mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
virsh: Introduce nvme disk to domblklist
This is slightly more complicated because NVMe disk source is not a simple attribute to <source/> element. The format in which the PCI address and namespace ID are printed is the same as QEMU accepts them: nvme://XXXX:XX:XX.X/X Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
430715604f
commit
67010e8749
@ -631,8 +631,8 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
||||
for (i = 0; i < ndisks; i++) {
|
||||
ctxt->node = disks[i];
|
||||
|
||||
if (details) {
|
||||
type = virXPathString("string(./@type)", ctxt);
|
||||
if (details) {
|
||||
device = virXPathString("string(./@device)", ctxt);
|
||||
if (!type || !device) {
|
||||
vshPrint(ctl, "unable to query block list details");
|
||||
@ -645,11 +645,30 @@ cmdDomblklist(vshControl *ctl, const vshCmd *cmd)
|
||||
vshError(ctl, "unable to query block list");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (STREQ_NULLABLE(type, "nvme")) {
|
||||
g_autofree char *namespace = NULL;
|
||||
virPCIDeviceAddress addr = { 0 };
|
||||
xmlNodePtr addrNode = NULL;
|
||||
|
||||
if (!(namespace = virXPathString("string(./source/@namespace)", ctxt)) ||
|
||||
!(addrNode = virXPathNode("./source/address", ctxt)) ||
|
||||
virPCIDeviceAddressParseXML(addrNode, &addr) < 0) {
|
||||
vshError(ctl, "Unable to query NVMe disk address");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
source = g_strdup_printf("nvme://%04x:%02x:%02x.%d/%s",
|
||||
addr.domain, addr.bus, addr.slot,
|
||||
addr.function, namespace);
|
||||
} else {
|
||||
source = virXPathString("string(./source/@file"
|
||||
"|./source/@dev"
|
||||
"|./source/@dir"
|
||||
"|./source/@name"
|
||||
"|./source/@volume)", ctxt);
|
||||
}
|
||||
|
||||
if (details) {
|
||||
if (vshTableRowAppend(table, type, device, target,
|
||||
NULLSTR_MINUS(source), NULL) < 0)
|
||||
|
Loading…
Reference in New Issue
Block a user