[libvirt] [PATCH] virsh: Option for overriding disk type in attach-disk
Daniel P. Berrange
berrange at redhat.com
Fri Sep 10 12:11:33 UTC 2010
On Fri, Sep 10, 2010 at 01:48:24PM +0200, Jiri Denemark wrote:
> Unless --driver tap|file option was given to attach-disk, virsh would
> generate <disk type='block'> XML which might be fine for Xen but not for
> other hypervisors. This patch introduces a new option --sourcetype which
> can be used to explicitly set the type of disk source. The option
> accepts either "file" or "block" types.
> ---
> tools/virsh.c | 12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 7bc33d8..57ea618 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -8116,6 +8116,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
> {"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")},
> + {"sourcetype", VSH_OT_STRING, 0, N_("type of source (block|file)")},
> {NULL, 0, 0, NULL}
> };
>
> @@ -8127,6 +8128,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
> int isFile = 0, ret = FALSE;
> char *buf = NULL, *tmp = NULL;
> unsigned int flags;
> + char *stype;
>
> if (!vshConnectionUsability(ctl, ctl->conn))
> goto cleanup;
> @@ -8144,10 +8146,16 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
> subdriver = vshCommandOptString(cmd, "subdriver", NULL);
> type = vshCommandOptString(cmd, "type", NULL);
> mode = vshCommandOptString(cmd, "mode", NULL);
> + stype = vshCommandOptString(cmd, "sourcetype", NULL);
>
> - if (driver) {
> - if (STREQ(driver, "file") || STREQ(driver, "tap"))
> + if (!stype) {
> + if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
> isFile = 1;
> + } else if (STREQ(stype, "file")) {
> + isFile = 1;
> + } else if (STRNEQ(stype, "block")) {
> + vshError(ctl, _("Unknown source type: '%s'"), stype);
> + goto cleanup;
> }
ACK
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list