<div dir="ltr"><div>It is better to format the patch summary like this format: "SUBSYSTEM: TITLE"</div><div>For example, this patch could be "virsh: Added a few attach-disk parameters"</div><div>You can see the git log of libvirt for more reference: <a href="https://libvirt.org/git/?p=libvirt.git;a=summary">https://libvirt.org/git/?p=libvirt.git;a=summary</a></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 11, 2020 at 5:58 AM Ryan Gahagan <<a href="mailto:rgahagan@cs.utexas.edu">rgahagan@cs.utexas.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: Ryan Gahagan <<a href="mailto:rgahagan@cs.utexas.edu" target="_blank">rgahagan@cs.utexas.edu</a>><br>
---<br>
 tools/virsh-domain.c | 76 +++++++++++++++++++++++++++++++++++++++-----<br>
 1 file changed, 68 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c<br>
index 12b35c037d..16227085cc 100644<br>
--- a/tools/virsh-domain.c<br>
+++ b/tools/virsh-domain.c<br>
@@ -224,6 +224,26 @@ static const vshCmdOptDef opts_attach_disk[] = {<br>
      .flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK,<br>
      .help = N_("source of disk device")<br>
     },<br>
+    {.name = "source-protocol",<br>
+     .type = VSH_OT_STRING,<br>
+     .help = N_("protocol used by disk device source")<br>
+    }<br>
+    {.name = "source-name",<br>
+     .type = VSH_OT_STRING,<br>
+     .help = N_("name of disk device source")<br>
+    },<br>
+    {.name = "source-host-name",<br>
+     .type = VSH_OT_STRING,<br>
+     .help = N_("host name for source of disk device")<br>
+    },<br>
+    {.name = "source-host-transport",<br>
+     .type = VSH_OT_STRING,<br>
+     .help = N_("host transport for source of disk device")<br>
+    },<br>
+    {.name = "source-host-socket",<br>
+     .type = VSH_OT_STRING,<br>
+     .help = N_("host socket for source of disk device")<br>
+    },<br>
     {.name = "target",<br>
      .type = VSH_OT_DATA,<br>
      .flags = VSH_OFLAG_REQ,<br>
@@ -562,11 +582,13 @@ static bool<br>
 cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)<br>
 {<br>
     virDomainPtr dom = NULL;<br>
-    const char *source = NULL, *target = NULL, *driver = NULL,<br>
-                *subdriver = NULL, *type = NULL, *mode = NULL,<br>
-                *iothread = NULL, *cache = NULL, *io = NULL,<br>
-                *serial = NULL, *straddr = NULL, *wwn = NULL,<br>
-                *targetbus = NULL, *alias = NULL;<br>
+    const char *source = NULL, *source_name = NULL, *source_protocol = NULL,<br>
+                *target = NULL, *driver = NULL, *subdriver = NULL, *type = NULL,<br>
+                *mode = NULL, *iothread = NULL, *cache = NULL,<br>
+                *io = NULL, *serial = NULL, *straddr = NULL,<br>
+                *wwn = NULL, *targetbus = NULL, *alias = NULL,<br>
+                *host_name = NULL, *host_transport = NULL,<br>
+                *host_port = NULL, *host_socket = NULL;<br>
     struct DiskAddress diskAddr;<br>
     bool isFile = false, functionReturn = false;<br>
     int ret;<br>
@@ -591,6 +613,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)<br>
         flags |= VIR_DOMAIN_AFFECT_LIVE;<br>
<br>
     if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||<br>
+        vshCommandOptStringReq(ctl, cmd, "source-name", &source_name) < 0 ||<br>
+        vshCommandOptStringReq(ctl, cmd, "source-protocol", &source_protocol) < 0 ||<br>
         vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||<br>
         vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 ||<br>
         vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 ||<br>
@@ -604,7 +628,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)<br>
         vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||<br>
         vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 ||<br>
         vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 ||<br>
-        vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0)<br>
+        vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0 ||<br>
+        vshCommandOptStringReq(ctl, cmd, "source-host-name", &host_name) < 0 ||<br>
+        vshCommandOptStringReq(ctl, cmd, "source-host-transport", &host_transport) < 0 ||<br>
+        vshCommandOptStringReq(ctl, cmd, "source-host-socket", &host_socket) < 0)<br>
         goto cleanup;<br>
<br>
     if (!stype) {<br>
@@ -659,9 +686,42 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)<br>
         virBufferAddLit(&buf, "/>\n");<br>
     }<br>
<br>
-    if (source)<br>
-        virBufferAsprintf(&buf, "<source %s='%s'/>\n",<br>
+    if (source || source_protocol || source_name ||<br>
+        host_name || host_transport || host_socket) {<br>
+        virBufferAsprintf(&buf, "<source");<br>
+<br>
+        if (source)<br>
+            virBufferAsprintf(&buf, " %s='%s'",<br>
                           isFile ? "file" : "dev", source);<br>
+        if (source_protocol)<br>
+            virBufferAsprintf(&buf, " protocol='%s'", source_protocol);<br>
+        if (source_name)<br>
+            virBufferAsprintf(&buf, " name='%s'", source_name);<br>
+<br>
+        if (host_name || host_transport || host_socket) {<br>
+            virBufferAsprintf(">\n<host");<br>
+<br>
+            if (host_name) {<br>
+                host_port = strchr(host_name, ':');<br>
+<br>
+                if (!host_port)<br>
+                    virBufferAsprintf(" name='%s'", host_name);<br>
+                else {<br>
+                    host_name[host_port - host_name] = '\0';<br>
+                    virBufferAsprintf(" name='%s' port='%s'", host_name, host_port + 1);<br>
+                }<br>
+            }<br>
+            if (host_transport)<br>
+                virBufferAsprintf(" transport='%s'", host_transport);<br>
+            if (host_socket)<br>
+                virBufferAsprintf(" socket='%s'", host_socket);<br>
+<br>
+            virBufferAsprintf(" />\n</source>\n");<br>
+        } else {<br>
+            virBufferAsprintf(" />\n");<br>
+        }<br>
+    }<br>
+<br>
     virBufferAsprintf(&buf, "<target dev='%s'", target);<br>
     if (targetbus)<br>
         virBufferAsprintf(&buf, " bus='%s'", targetbus);<br>
-- <br>
2.29.0<br>
<br>
</blockquote></div>