[PATCH 1/3] add --cache option for attach-disk

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

 



Add --cache option to allow user to specify cache mode of disk device
from virsh command line when attaching a disk device.
---
 tools/virsh.c   |   10 ++++++++--
 tools/virsh.pod |    5 +++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 9a189fd..cab5a35 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10176,6 +10176,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     {"target",  VSH_OT_DATA, VSH_OFLAG_REQ, N_("target of disk device")},
     {"driver",    VSH_OT_STRING, 0, N_("driver of disk device")},
     {"subdriver", VSH_OT_STRING, 0, N_("subdriver of disk device")},
+    {"cache",     VSH_OT_STRING, 0, N_("cache mode of disk device")},
     {"type",    VSH_OT_STRING, 0, N_("target device type")},
     {"mode",    VSH_OT_STRING, 0, N_("mode of device reading and writing")},
     {"persistent", VSH_OT_BOOL, 0, N_("persist disk attachment")},
@@ -10188,7 +10189,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom = NULL;
     const char *source = NULL, *target = NULL, *driver = NULL,
-                *subdriver = NULL, *type = NULL, *mode = NULL;
+                *subdriver = NULL, *type = NULL, *mode = NULL,
+                *cache = NULL;
     bool isFile = false, functionReturn = false;
     int ret;
     unsigned int flags;
@@ -10217,6 +10219,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         goto cleanup;
     }
 
+    ignore_value(vshCommandOptString(cmd, "cache", &cache));
+
     if (!stype) {
         if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
             isFile = true;
@@ -10249,8 +10253,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         virBufferAsprintf(&buf, " name='%s'", driver);
     if (subdriver)
         virBufferAsprintf(&buf, " type='%s'", subdriver);
+    if (cache)
+        virBufferAsprintf(&buf, " cache='%s'", cache);
 
-    if (driver || subdriver)
+    if (driver || subdriver || cache)
         virBufferAddLit(&buf, "/>\n");
 
     virBufferAsprintf(&buf, "  <source %s='%s'/>\n",
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 736b919..79f49ba 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -874,8 +874,8 @@ For cdrom and floppy devices, this command only replaces the media within
 the single existing device; consider using B<update-device> for this usage.
 
 =item B<attach-disk> I<domain-id> I<source> I<target> optional
-I<--driver driver> I<--subdriver subdriver> I<--type type>
-I<--mode mode> I<--persistent> I<--sourcetype soucetype>
+I<--driver driver> I<--subdriver subdriver> I<--cache cache>
+I<--type type> I<--mode mode> I<--persistent> I<--sourcetype soucetype>
 
 Attach a new disk device to the domain.
 I<source> and I<target> are paths for the files and devices.
@@ -886,6 +886,7 @@ floppy device; consider using B<update-device> for this usage instead.
 I<mode> can specify the two specific mode I<readonly> or I<shareable>.
 I<persistent> indicates the changes will affect the next boot of the domain.
 I<sourcetype> can indicate the type of source (block|file)
+I<cache> can be one of "default", "none", "writethrough" or "writeback".
 
 =item B<attach-interface> I<domain-id> I<type> I<source> optional
 I<--target target> I<--mac mac> I<--script script> I<--model model>
-- 
1.7.5.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]