virsh: Add missing TAB completers for 'attach-disk' command

Add enum and static-list completers for 'attach-disk' options
targetbus, type, cache, io, mode, and sourcetype, and reuse the
existing storage file format completer for subdriver.

Partially-fixes: https://gitlab.com/libvirt/libvirt/-/work_items/9
Signed-off-by: Radoslaw Smigielski <rsmigiel@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Radoslaw Smigielski authored and Peter Krempa committed 2026-08-13 17:19:51 +02:00
1 parent 44077b7aee
commit 71e9a0ec2c
3 files changed
+112

No files matched your search

+74
View File
@@ -1183,3 +1183,77 @@ virshDomainXMLNativeFormatCompleter(vshControl *ctl,
return vshCommaStringListComplete(NULL, formats);
}
char **
virshDomainDiskBusCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
virCheckFlags(0, NULL);
return vshEnumComplete(VIR_DOMAIN_DISK_BUS_LAST,
virDomainDiskBusTypeToString);
}
char **
virshDomainDiskDeviceTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
virCheckFlags(0, NULL);
return vshEnumComplete(VIR_DOMAIN_DISK_DEVICE_LAST,
virDomainDiskDeviceTypeToString);
}
char **
virshDomainDiskCacheCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
virCheckFlags(0, NULL);
return vshEnumComplete(VIR_DOMAIN_DISK_CACHE_LAST,
virDomainDiskCacheTypeToString);
}
char **
virshDomainDiskIoCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
virCheckFlags(0, NULL);
return vshEnumComplete(VIR_DOMAIN_DISK_IO_LAST,
virDomainDiskIoTypeToString);
}
char **
virshDomainAttachDiskModeCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
static const char *modes[] = {"readonly", "shareable", NULL};
virCheckFlags(0, NULL);
return vshCommaStringListComplete(NULL, modes);
}
char **
virshDomainAttachDiskSourceTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
static const char *types[] = {"file", "block", "network", NULL};
virCheckFlags(0, NULL);
return vshCommaStringListComplete(NULL, types);
}
+30
View File
@@ -214,3 +214,33 @@ char **
virshDomainXMLNativeFormatCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainDiskBusCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainDiskDeviceTypeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainDiskCacheCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainDiskIoCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainAttachDiskModeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainAttachDiskSourceTypeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
+8
View File
@@ -435,6 +435,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
},
{.name = "targetbus",
.type = VSH_OT_STRING,
.completer = virshDomainDiskBusCompleter,
.help = N_("target bus of disk device")
},
{.name = "driver",
@@ -443,6 +444,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
},
{.name = "subdriver",
.type = VSH_OT_STRING,
.completer = virshDomainStorageFileFormatCompleter,
.help = N_("subdriver of disk device")
},
{.name = "iothread",
@@ -452,14 +454,17 @@ static const vshCmdOptDef opts_attach_disk[] = {
},
{.name = "cache",
.type = VSH_OT_STRING,
.completer = virshDomainDiskCacheCompleter,
.help = N_("cache mode of disk device")
},
{.name = "io",
.type = VSH_OT_STRING,
.completer = virshDomainDiskIoCompleter,
.help = N_("io policy of disk device")
},
{.name = "type",
.type = VSH_OT_STRING,
.completer = virshDomainDiskDeviceTypeCompleter,
.help = N_("target device type")
},
{.name = "shareable",
@@ -468,10 +473,12 @@ static const vshCmdOptDef opts_attach_disk[] = {
},
{.name = "mode",
.type = VSH_OT_STRING,
.completer = virshDomainAttachDiskModeCompleter,
.help = N_("mode of device reading and writing")
},
{.name = "sourcetype",
.type = VSH_OT_STRING,
.completer = virshDomainAttachDiskSourceTypeCompleter,
.help = N_("type of source (block|file|network)")
},
{.name = "serial",
@@ -521,6 +528,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
},
{.name = "source-host-socket",
.type = VSH_OT_STRING,
.completer = vshCompletePathLocalExisting,
.help = N_("host socket for source of disk device")
},
{.name = "throttle-groups",