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

[libvirt] [PATCH]virsh: support readonly in attach-disk command

From: Chen Hanxiao <chenhanxiao cn fujitsu com>

support readonly in attach-disk virsh command
with option --readonly

Signed-off-by: Chen Hanxiao <chenhanxiao cn fujitsu com>
 tools/virsh-domain.c | 7 +++++++
 tools/virsh.pod      | 5 +++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 3479a1c..d334ebe 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -315,6 +315,10 @@ static const vshCmdOptDef opts_attach_disk[] = {
      .type = VSH_OT_BOOL,
      .help = N_("shareable between domains")
+    {.name = "readonly",
+     .type = VSH_OT_BOOL,
+     .help = N_("allow guest read-only access to disk")
+    },
     {.name = "rawio",
      .type = VSH_OT_BOOL,
      .help = N_("needs rawio capability")
@@ -612,6 +616,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "shareable"))
         virBufferAddLit(&buf, "  <shareable/>\n");
+    if (vshCommandOptBool(cmd, "readonly"))
+        virBufferAddLit(&buf, "  <readonly/>\n");
     if (straddr) {
         if (str2DiskAddress(straddr, &diskAddr) != 0) {
             vshError(ctl, _("Invalid address."));
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 0ae5178..91b4429 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -1908,8 +1908,8 @@ expected.
 [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
 [I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>]
 [I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>]
-[I<--serial serial>] [I<--wwn wwn>] [I<--shareable>] [I<--rawio>]
-[I<--address address>] [I<--multifunction>] [I<--print-xml>]
+[I<--serial serial>] [I<--wwn wwn>] [I<--shareable>] [I<--readonly>]
+[I<--rawio>] [I<--address address>] [I<--multifunction>] [I<--print-xml>]
 Attach a new disk device to the domain.
 I<source> is path for the files and devices. I<target> controls the bus or
@@ -1931,6 +1931,7 @@ I<cache> can be one of "default", "none", "writethrough", "writeback",
 "directsync" or "unsafe".
 I<serial> is the serial of disk device. I<wwn> is the wwn of disk device.
 I<shareable> indicates the disk device is shareable between domains.
+I<readonly> indicates the disk device is read-only.
 I<rawio> indicates the disk needs rawio capability.
 I<address> is the address of disk device in the form of pci:domain.bus.slot.function,
 scsi:controller.bus.unit or ide:controller.bus.unit.

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