[libvirt] [PATCH 3/4] Add a new 'virsh qemu-attach' command.
Eric Blake
eblake at redhat.com
Thu May 5 22:44:10 UTC 2011
On 05/05/2011 11:26 AM, Daniel P. Berrange wrote:
> This command allows libvirt to attach to an existing QEMU
> instance.
>
> $ qemu-kvm -cdrom ~/demo.iso \
> -monitor unix:/tmp/demo,server,nowait \
> -name foo \
> -uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea &
> $ QEMUPID=$$
$!, not $$ (you want to attach to the background qemu, not your current
shell!)
> $ virsh qemu-attach $QEMUPID
> ---
> tools/virsh.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 47 insertions(+), 0 deletions(-)
>
> +static const vshCmdOptDef opts_qemu_attach[] = {
> + {"pid", VSH_OT_DATA, VSH_OFLAG_REQ, N_("pid")},
s/VSH_OT_DATA/VSH_OT_INT/
> + {NULL, 0, 0, NULL}
> +};
> +
> +static bool
> +cmdQemuAttach(vshControl *ctl, const vshCmd *cmd)
> +{
> + virDomainPtr dom = NULL;
> + bool ret = false;
> + unsigned int flags = 0;
> + int pid;
> +
> + if (!vshConnectionUsability(ctl, ctl->conn))
> + goto cleanup;
> +
> + if (vshCommandOptInt(cmd, "pid", &pid) < 0) {
s/</<=/ - pid is a required argument. Since you didn't initialize it,
if vshCommandOptInt returns 0, you would be using whatever garbage was
on the stack.
> @@ -10875,6 +10921,7 @@ static const vshCmdDef hostAndHypervisorCmds[] = {
> {"hostname", cmdHostname, NULL, info_hostname},
> {"nodeinfo", cmdNodeinfo, NULL, info_nodeinfo},
> {"qemu-monitor-command", cmdQemuMonitorCommand, opts_qemu_monitor_command, info_qemu_monitor_command},
> + {"qemu-attach", cmdQemuAttach, opts_qemu_attach, info_qemu_attach},
Swap the above two lines, to keep alphabetical order.
Missing tools/virsh.pod changes. You know I can't ack without
documentation... :)
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110505/1d7f7b74/attachment-0001.sig>
More information about the libvir-list
mailing list