[PATCH 03/10] virsh: Add transient flag for disk hotplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx>

Enable <transient/> disk option for the xml to hotplug disks.
And <shareable/> disk option is also available for the disk to
share the disk with multiple guests.
For example:

  # cat disk.xml
  <disk type='file' device='disk'>
    <driver name='qemu' type='qcow2'/>
    <source file='/var/lib/libvirt/images/disk.qcow2'/>
    <target dev='vdf' bus='virtio'/>
    <shareable/>
    <transient/>
  </disk>
  #
  # virsh attach-device Guest1 disk.xml
  Device attached successfully

  #
  # virsh attach-device Guest2 disk.xml
  Device attached successfully

  #

Signed-off-by: Masayoshi Mizuma <m.mizuma@xxxxxxxxxxxxxx>
---
 tools/virsh-domain.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a778421b66..7246260673 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -486,6 +486,10 @@ static const vshCmdOptDef opts_attach_disk[] = {
      .type = VSH_OT_STRING,
      .help = N_("host socket for source of disk device")
     },
+    {.name = "transient",
+     .type = VSH_OT_BOOL,
+     .help = N_("mark the disk as transient")
+    },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
     VIRSH_COMMON_OPT_DOMAIN_LIVE,
@@ -593,6 +597,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     bool live = vshCommandOptBool(cmd, "live");
     bool persistent = vshCommandOptBool(cmd, "persistent");
     bool multifunction = vshCommandOptBool(cmd, "multifunction");
+    bool transient = vshCommandOptBool(cmd, "transient");
 
     VSH_EXCLUSIVE_OPTIONS_VAR(persistent, current);
 
@@ -739,6 +744,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         cmdAttachDiskFormatAddress(ctl, &diskChildBuf, straddr, target, multifunction) < 0)
         return false;
 
+    if (transient)
+        virBufferAddLit(&diskChildBuf, "<transient/>\n");
+
     virXMLFormatElement(&buf, "disk", &diskAttrBuf, &diskChildBuf);
 
     xml = virBufferContentAndReset(&buf);
-- 
2.27.0




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux