From e1b75dc5003e363d833044d0d3ae497f4c0075af Mon Sep 17 00:00:00 2001 From: Han Han Date: Sun, 15 Jul 2018 18:08:17 +0800 Subject: [PATCH] virsh: Support alias in attach-interface Add --alias to support custom alias in virsh attach-interface. Signed-off-by: Han Han Signed-off-by: Michal Privoznik --- tools/virsh-domain.c | 10 +++++++++- tools/virsh.pod | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a6fd1ceb2d..c1cff9fe2d 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -837,6 +837,10 @@ static const vshCmdOptDef opts_attach_interface[] = { .type = VSH_OT_STRING, .help = N_("model type") }, + {.name = "alias", + .type = VSH_OT_STRING, + .help = N_("custom alias name of interface device") + }, {.name = "inbound", .type = VSH_OT_STRING, .help = N_("control domain's incoming traffics") @@ -910,7 +914,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) virDomainPtr dom = NULL; const char *mac = NULL, *target = NULL, *script = NULL, *type = NULL, *source = NULL, *model = NULL, - *inboundStr = NULL, *outboundStr = NULL; + *inboundStr = NULL, *outboundStr = NULL, *alias = NULL; virNetDevBandwidthRate inbound, outbound; virDomainNetType typ; int ret; @@ -940,6 +944,7 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "mac", &mac) < 0 || vshCommandOptStringReq(ctl, cmd, "script", &script) < 0 || vshCommandOptStringReq(ctl, cmd, "model", &model) < 0 || + vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || vshCommandOptStringReq(ctl, cmd, "inbound", &inboundStr) < 0 || vshCommandOptStringReq(ctl, cmd, "outbound", &outboundStr) < 0) goto cleanup; @@ -1037,6 +1042,9 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) if (model != NULL) virBufferAsprintf(&buf, "\n", model); + if (alias != NULL) + virBufferAsprintf(&buf, "\n", alias); + if (inboundStr || outboundStr) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); diff --git a/tools/virsh.pod b/tools/virsh.pod index a7fb8ab82c..a5e02c62cd 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -3090,7 +3090,7 @@ Likewise, I<--shareable> is an alias for I<--mode shareable>. [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]] [I<--target target>] [I<--mac mac>] [I<--script script>] [I<--model model>] [I<--inbound average,peak,burst,floor>] [I<--outbound average,peak,burst>] -[I<--managed>] [I<--print-xml>] +[I<--alias alias>] [I<--managed>] [I<--print-xml>] Attach a new network interface to the domain. @@ -3144,6 +3144,8 @@ I type and only for Xen domains. B<--model> specifies the network device model to be presented to the domain. +B can set user supplied alias. + B<--inbound> and B<--outbound> control the bandwidth of the interface. At least one from the I, I pair must be specified. The other two I and I are optional, so