[libvirt] [PATCH 0/5] Add LibSSH2 transport
by Peter Krempa
This patchset adds LibSSH2 transport implementation for libvirt's virNetSocket
object and other needed places to enable connections using the native library
instead of spawning the ssh client and communicating using pipes.
This patchset lacks addition of documentation (I'll do that later, but I'd like
to get the code sorted out) but
otherwise should be fully functional.
The commit message to the last patch describes the configuration variables used
to set parameters of the transport. The setting is done using uri arguments.
Thanks in advance for reviews and comments :)
Peter
Peter Krempa (5):
remote: Clean up coding style and refactor remote connection opening
libssh2_transport: add main libssh2 transport implementation
libssh2_transport: add ssh context support to virNetSocket
libssh2_transport: Add libssh2 session support to net client code
libssh2_transport: Use libssh2 driver code in remote driver
configure.ac | 40 +-
include/libvirt/virterror.h | 2 +
po/POTFILES.in | 1 +
src/Makefile.am | 9 +
src/libvirt_private.syms | 1 +
src/remote/remote_driver.c | 339 ++++++-----
src/rpc/virnetclient.c | 120 ++++-
src/rpc/virnetclient.h | 14 +-
src/rpc/virnetlibsshcontext.c | 1444 +++++++++++++++++++++++++++++++++++++++++
src/rpc/virnetlibsshcontext.h | 83 +++
src/rpc/virnetsocket.c | 178 +++++-
src/rpc/virnetsocket.h | 13 +
src/util/virterror.c | 8 +-
13 files changed, 2092 insertions(+), 160 deletions(-)
create mode 100644 src/rpc/virnetlibsshcontext.c
create mode 100644 src/rpc/virnetlibsshcontext.h
--
1.7.8.6
12 years, 3 months
[libvirt] libvirt sgefaults upon ctrl-c
by Stefan Berger
Hi,
libvirt segfaults for me when run in the foreground and pressing ctrl-c.
A bisect of the code lead me to this commit
commit 7c1119e3bbd483c52ae4cdfebe23dd179ad28124
Author: Daniel P. Berrange <berrange(a)redhat.com>
Date: Tue Aug 7 12:02:06 2012 +0100
Stefan
12 years, 3 months
[libvirt] [PATCH 2/5] add qemuAgentCommand()
by MATSUDA, Daiki
Add qemuAgentCommand() for general qemu agent command.
include/libvirt/libvirt-qemu.h | 5 +++++
src/qemu/qemu_agent.c | 38 ++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_agent.h | 5 +++++
3 files changed, 48 insertions(+)
diff --git a/include/libvirt/libvirt-qemu.h b/include/libvirt/libvirt-qemu.h
index a37f897..ffc5ae5 100644
--- a/include/libvirt/libvirt-qemu.h
+++ b/include/libvirt/libvirt-qemu.h
@@ -44,6 +44,11 @@ virDomainPtr virDomainQemuAttach(virConnectPtr domain,
unsigned int pid_value,
unsigned int flags);
+typedef enum {
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK = -1,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_NOWAIT = 0,
+} virDomainQemuAgentCommandTimeoutFlags;
+
# ifdef __cplusplus
}
# endif
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 7699042..1cfcafc 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -1401,3 +1401,41 @@ qemuAgentSuspend(qemuAgentPtr mon,
virJSONValueFree(reply);
return ret;
}
+
+int qemuAgentQemuAgentCommand(qemuAgentPtr mon,
+ const char *cmd_str,
+ char **result,
+ int timeout)
+{
+ int ret = -1;
+ int seconds;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ cmd = virJSONValueFromString(cmd_str);
+ if (!cmd)
+ return ret;
+
+ if (result == NULL) {
+ seconds = 0;
+ } else if (timeout == VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) {
+ seconds = 5;
+ } else {
+ seconds = timeout;
+ }
+
+repeat:
+ ret = qemuAgentCommand(mon, cmd, &reply, timeout);
+
+ if (ret == 0) {
+ ret = qemuAgentCheckError(cmd, reply);
+ *result = virJSONValueToString(reply);
+ } else {
+ if (timeout == VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK) goto repeat;
+ *result = NULL;
+ }
+
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
index 2fdebb2..fc19c2f 100644
--- a/src/qemu/qemu_agent.h
+++ b/src/qemu/qemu_agent.h
@@ -77,4 +77,9 @@ int qemuAgentFSThaw(qemuAgentPtr mon);
int qemuAgentSuspend(qemuAgentPtr mon,
unsigned int target);
+
+int qemuAgentQemuAgentCommand(qemuAgentPtr mon,
+ const char *cmd,
+ char **result,
+ int timeout);
#endif /* __QEMU_AGENT_H__ */
12 years, 3 months
[libvirt] Channel with virtio problem
by norazah aziz
I have configured the kvm and edit the xml as below, however there are an error when I want to run the guest. The error as follows:
virsh create libvirt.xml
error: Failed to create domain from libvirt-test.xml
error: XML description for unknown target type for character device: virtio is not well formed or invalid
Please help me to solve this problem.
############################################################
<domain type='kvm'>
<name>i-5E36098H</name>
<os>
<type>hvm</type>
<kernel>/opt/eucalyptus-data/suria/i-5E36098H/kernel</kernel>
<initrd>/opt/eucalyptus-data/suria/i-5E36098H/ramdisk</initrd>
<cmdline>root=LABEL=root console=ttyS0</cmdline>
</os>
<features>
<acpi/>
</features>
<memory>13107200</memory>
<vcpu>1</vcpu>
<devices>
<emulator>/usr/bin/kvm</emulator>
<disk type='file'>
<source file='/opt/eucalyptus-data/suria/i-5E36098H/disk'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='network'>
<source network='default'/>
<mac address='d0:0d:45:D2:08:01'/>
<model type='virtio'/>
</interface>
<controller type='ide' index='0'/>
<controller type='virtio-serial' index='0' ports='16' vectors='4'/>
<controller type='virtio-serial' index='1'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</controller>
<parallel type='pty'>
<source path='/dev/pts/2'/>
<target port='0'/>
</parallel>
<serial type='pty'>
<source path='/dev/pts/3'/>
<!-- <source mode='bind' path='/var/lib/libvirt/qemu/va-i-5E36098H-isa.sock'/>-->
<target type='virtio' port='0'/>
</serial>
<console type='pty'>
<source path='/dev/pts/4'/>
<target type='virtio' port='0'/>
</console>
<channel type='pty'>
<source mode='bind' path='/var/lib/libvirt/qemu/va-i5E36098H-virtio.sock'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
<address type='virtio-serial' controller='0' bus='0' port='0'/>
</channel>
<graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/>
</devices>
########################################################################
12 years, 3 months
[libvirt] [PATCH] Allow rbd backing stores
by Peter Feiner
Prevents libvirt from treating RBD backing stores as files. Without this
patch,
creating a domain with a qcow2 overlay on an RBD would fail.
This patch essentially extends 9c7c4a4fc533598e59e9a0038ec783e61a38e664,
which allows nbd backing stores, to allow rbd backing stores.
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index f38aa8e..101518a 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -589,8 +589,8 @@ virStorageFileMatchesVersion(int format,
static bool
virBackingStoreIsFile(const char *backing)
{
- /* Backing store is a network block device */
- if (STRPREFIX(backing, "nbd:"))
+ /* Backing store is a network block device or Rados block device */
+ if (STRPREFIX(backing, "nbd:") || STRPREFIX(backing, "rbd:"))
return false;
return true;
}
12 years, 3 months
[libvirt] [PATCH] Fix errno check, prevent spurious errors under heavy load
by Peter Feiner
>From man poll(2), poll does not set errno=EAGAIN, however it does set
errno=EINTR. Have libvirt retry on the appropriate errno.
Under heavy load, a program of mine kept getting libvirt errors 'poll on
socket
failed: Interrupted system call'. The signals were SIGCHLD from processes
forked
by threads unrelated to those using libvirt.
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index 2530ffa..f2a6922 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -1374,7 +1374,7 @@ static int virNetClientIOEventLoop(virNetClientPtr
client,
repoll:
ret = poll(fds, ARRAY_CARDINALITY(fds), timeout);
- if (ret < 0 && errno == EAGAIN)
+ if (ret < 0 && errno == EINTR)
goto repoll;
ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
12 years, 3 months
[libvirt] [PATCH V3][TCK] Add test for memory set and get
by Kyla Zhang
Add test for memory/maxmem setting and getting on domain active/inactive
---
scripts/domain/110-memory-balloon.t | 113 +++++++++++++++++++++++++++++++++++
1 files changed, 113 insertions(+), 0 deletions(-)
create mode 100644 scripts/domain/110-memory-balloon.t
diff --git a/scripts/domain/110-memory-balloon.t b/scripts/domain/110-memory-balloon.t
new file mode 100644
index 0000000..a3e463c
--- /dev/null
+++ b/scripts/domain/110-memory-balloon.t
@@ -0,0 +1,113 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Kyla Zhang <weizhan(a)redhat.com>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+domain/110-memory-balloon.t: test setting and getting memory/max memory
+
+=head1 DESCRIPTION
+
+The testcase validates the basic function of domain memory balloon via setting
+its value of current memory, max memory.
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 15;
+
+use Sys::Virt::TCK;
+use Sys::Virt::TCK::NetworkHelpers;
+use Test::Exception;
+use File::Spec::Functions qw(catfile catdir rootdir);
+
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END { $tck->cleanup if $tck; }
+
+diag "Define a new real domain, default memory is 1048576";
+my $dom_name ="tckmemballoon";
+my $default_mem = 1048576;
+my $max_mem1 = 1572864;
+my $max_mem2 = 1148576;
+my $config_mem = 924288;
+my $live_mem = 824288;
+my $current_mem = 724288;
+
+# Install a guest with default memory size
+my $dom = prepare_test_disk_and_vm($tck, $conn, $dom_name);
+
+
+diag "Set max memory for inactive domain";
+lives_ok(sub { $dom->set_max_memory("$max_mem1") }, "Set max memory $max_mem1");
+diag "Get max memory from inactive domain";
+is($dom->get_max_memory(), $max_mem1, "Get max memory $max_mem1");
+
+
+diag "Start domain";
+$dom->create;
+ok($dom->get_id() > 0, "running domain has an ID > 0");
+sleep(30);
+
+diag "Get max memory for domain when domain is active";
+is($dom->get_max_memory(), $max_mem1, "Get max memory is $max_mem1");
+
+
+diag "Set memory with flag MEM_CONFIG";
+lives_ok(sub { $dom->set_memory("$config_mem", Sys::Virt::Domain::MEM_CONFIG) },
+ "Set persistent memory value $config_mem");
+diag "Get current memory";
+is($dom->get_info()->{memory}, $default_mem, "Get current memory is $default_mem");
+
+
+diag "Set memory with flag MEM_CURRENT";
+lives_ok(sub { $dom->set_memory("$current_mem", Sys::Virt::Domain::MEM_CURRENT) },
+ "Set current memory value $current_mem");
+sleep(3);
+diag "Get current memory";
+is($dom->get_info()->{memory}, $current_mem, "Get current memory is $current_mem");
+
+
+diag "Set memory with flag MEM_LIVE";
+lives_ok(sub { $dom->set_memory("$live_mem", Sys::Virt::Domain::MEM_LIVE) },
+ "Set live memory value $live_mem");
+sleep(3);
+diag "Get current memory";
+is($dom->get_info()->{memory}, $live_mem, "Get current memory is $live_mem");
+
+
+diag "Set max memory for running domain";
+ok_error(sub { $dom->set_max_memory("$default_mem") }, "Not allowed to set max memory for running domain");
+
+diag "Destroy domain";
+$dom->destroy;
+
+diag "Get current memory";
+is($dom->get_info()->{memory}, $config_mem, "Get current memory is $config_mem");
+
+
+diag "Set max memory with set_memory";
+lives_ok(sub { $dom->set_memory("$max_mem2", Sys::Virt::Domain::MEM_MAXIMUM) },
+ "Set max memory $max_mem2");
+diag "Get max memory";
+is($dom->get_info()->{maxMem}, $max_mem2, "Get max memory is $max_mem2");
+
+
+diag "Setting memory with flag MEM_LIVE for inactive domain";
+ok_error(sub { $dom->set_memory("$live_mem", Sys::Virt::Domain::MEM_LIVE) },
+ "Not allowed to set memory with flag MEM_LIVE for inactive domain");
--
1.7.1
12 years, 3 months
[libvirt] [PATCH V3] Add proxy FS support to libvirt
by M. Mohan Kumar
From: "M. Mohan Kumar" <mohan(a)in.ibm.com>
A new FS driver type 'proxy' is added to QEMU 9p server. This patch adds
support for using proxy FS driver from libvirt.
QEMU proxy FS driver uses socket for communicating between helper and qemu
proxy FS driver. Proxy helper (a stand alone binary part of qemu) is invoked
with one of the descriptors created using socketpair call and the share path.
Similarly QEMU is invoked with another descriptor created using the same
socketpair system call and with other required FS driver parameters.
Need for proxy FS driver
========================
Pass through security model in QEMU 9p server has following issues:
1) TOCTTOU vulnerability: Following symbolic links in the server could
provide access to files beyond 9p export path.
2) Running QEMU with root privilege could be a security issue (pass
through security model needs root privilege).
Proxy FS driver is implemented to solve these issues.
Proxy FS uses chroot + socket combination for securing the vulnerability
known with following symbolic links. Intention of adding a new filesystem
type is to allow qemu to run in non-root mode, but doing privileged
operations in a chroot environment using socket IO.
Proxy helper is invoked with root privileges and chroots into 9p export path.
QEMU proxy fs driver sends filesystem request to proxy helper and receives the
response from it.
Proxy helper is designed such a way that it needs only few capabilities related
to filesystem operations (such as CAP_DAC_OVERRIDE, CAP_FOWNER, etc) and all
other capabilities are dropped (CAP_SYS_CHROOT, etc)
Proxy patches
http://permalink.gmane.org/gmane.comp.emulators.qemu/128735
Signed-off-by: M. Mohan Kumar <mohan(a)in.ibm.com>
---
Changes from V2
* Rebased on top of current libvirt git level
Changes from previous version
* Remove the xml node for specifying the virtfs-proxy-helper path, now it is
determined from qemu binary path.
docs/formatdomain.html.in | 2 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_capabilities.c | 5 ++-
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 71 ++++++++++++++++++++++++++++++++++++++++--
src/qemu/qemu_command.h | 3 +-
tests/qemuhelptest.c | 6 ++-
8 files changed, 83 insertions(+), 10 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index f97c630..7242455 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1619,6 +1619,8 @@
while the value <code>immediate</code> means that a host writeback
is immediately triggered for all pages touched during a guest file
write operation <span class="since">(since 0.9.10)</span>.
+ or <code>type='proxy'</code> <span class="since">(since
+ 1.0)</span>.
</dd>
<dt><code>type='template'</code></dt>
<dd>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 58603a3..70b145d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -273,7 +273,8 @@ VIR_ENUM_IMPL(virDomainFS, VIR_DOMAIN_FS_TYPE_LAST,
VIR_ENUM_IMPL(virDomainFSDriverType, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
"default",
"path",
- "handle")
+ "handle",
+ "proxy")
VIR_ENUM_IMPL(virDomainFSAccessMode, VIR_DOMAIN_FS_ACCESSMODE_LAST,
"passthrough",
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index f4c43c6..6ea62a3 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -675,6 +675,7 @@ enum virDomainFSDriverType {
VIR_DOMAIN_FS_DRIVER_TYPE_DEFAULT = 0,
VIR_DOMAIN_FS_DRIVER_TYPE_PATH,
VIR_DOMAIN_FS_DRIVER_TYPE_HANDLE,
+ VIR_DOMAIN_FS_DRIVER_TYPE_PROXY,
VIR_DOMAIN_FS_DRIVER_TYPE_LAST
};
@@ -713,7 +714,6 @@ struct _virDomainFSDef {
unsigned long long space_soft_limit; /* in bytes */
};
-
/* 5 different types of networking config */
enum virDomainNetType {
VIR_DOMAIN_NET_TYPE_USER,
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 85c49a2..d582549 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -144,7 +144,6 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"ich9-ahci",
"no-acpi",
"fsdev-readonly",
-
"virtio-blk-pci.scsi", /* 80 */
"blk-sg-io",
"drive-copy-on-read",
@@ -168,7 +167,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"nec-usb-xhci",
"virtio-s390",
"balloon-event",
-
+ "fsdev-proxy", /* 100 */
);
struct qemu_feature_flags {
@@ -1129,6 +1128,8 @@ qemuCapsComputeCmdFlags(const char *help,
qemuCapsSet(flags, QEMU_CAPS_FSDEV_READONLY);
if (strstr(fsdev, "writeout"))
qemuCapsSet(flags, QEMU_CAPS_FSDEV_WRITEOUT);
+ if (strstr(fsdev, "sock_fd"))
+ qemuCapsSet(flags, QEMU_CAPS_FSDEV_PROXY);
}
if (strstr(help, "-smbios type"))
qemuCapsSet(flags, QEMU_CAPS_SMBIOS_TYPE);
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index e8251dc..e48d623 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -135,6 +135,7 @@ enum qemuCapsFlags {
QEMU_CAPS_NEC_USB_XHCI = 97, /* -device nec-usb-xhci */
QEMU_CAPS_VIRTIO_S390 = 98, /* -device virtio-*-s390 */
QEMU_CAPS_BALLOON_EVENT = 99, /* Async event for balloon changes */
+ QEMU_CAPS_FSDEV_PROXY = 100, /* -fsdev proxy supported */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 6ad65a6..af689f8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -44,6 +44,7 @@
#include <sys/utsname.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <libgen.h>
#define VIR_FROM_THIS VIR_FROM_QEMU
@@ -114,7 +115,8 @@ VIR_ENUM_DECL(qemuDomainFSDriver)
VIR_ENUM_IMPL(qemuDomainFSDriver, VIR_DOMAIN_FS_DRIVER_TYPE_LAST,
"local",
"local",
- "handle");
+ "handle",
+ "proxy");
static void
@@ -2575,9 +2577,43 @@ error:
return NULL;
}
+/*
+ * Invokes the Proxy Helper with one of the socketpair as its parameter
+ *
+ */
+static int qemuInvokeProxyHelper(const char *emulator, int sock, const char *path)
+{
+#define HELPER "virtfs-proxy-helper"
+ int ret_val, status;
+ virCommandPtr cmd;
+ char *helper, *dname;
+
+ dname = dirname(strdup(emulator));
+ if (virAsprintf(&helper, "%s/%s", dname, HELPER) < 0) {
+ VIR_FREE(dname);
+ virReportOOMError();
+ return -1;
+ }
+
+ cmd = virCommandNewArgList(helper, NULL);
+ virCommandAddArg(cmd, "-f");
+ virCommandAddArgFormat(cmd, "%d", sock);
+ virCommandAddArg(cmd, "-p");
+ virCommandAddArgFormat(cmd, "%s", path);
+ virCommandTransferFD(cmd, sock);
+ virCommandDaemonize(cmd);
+ ret_val = virCommandRun(cmd, &status);
+ if (ret_val < 0)
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("%s can't execute"), helper);
+ virCommandFree(cmd);
+ VIR_FREE(helper);
+ VIR_FREE(dname);
+ return ret_val;
+}
char *qemuBuildFSStr(virDomainFSDefPtr fs,
- virBitmapPtr qemuCaps ATTRIBUTE_UNUSED)
+ virBitmapPtr qemuCaps ATTRIBUTE_UNUSED, int qemuSocket)
{
virBuffer opt = VIR_BUFFER_INITIALIZER;
const char *driver = qemuDomainFSDriverTypeToString(fs->fsdriver);
@@ -2626,6 +2662,10 @@ char *qemuBuildFSStr(virDomainFSDefPtr fs,
}
virBufferAsprintf(&opt, ",id=%s%s", QEMU_FSDEV_HOST_PREFIX, fs->info.alias);
+
+ if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_PROXY)
+ virBufferAsprintf(&opt, ",sock_fd=%d", qemuSocket);
+
virBufferAsprintf(&opt, ",path=%s", fs->src);
if (fs->readonly) {
@@ -5081,10 +5121,35 @@ qemuBuildCommandLine(virConnectPtr conn,
if (qemuCapsGet(qemuCaps, QEMU_CAPS_FSDEV)) {
for (i = 0 ; i < def->nfss ; i++) {
char *optstr;
+ int sockets[2] = {-1, -1};
virDomainFSDefPtr fs = def->fss[i];
+ /*
+ * If its a proxy FS, we need to create a socket pair
+ * and invoke proxy_helper
+ */
+ if (fs->fsdriver == VIR_DOMAIN_FS_DRIVER_TYPE_PROXY) {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_FSDEV_PROXY) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("proxy helper not supported"));
+ goto error;
+ }
+ /* create a socket pair */
+ if (socketpair(PF_UNIX, SOCK_STREAM, 0, sockets) < 0) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("socketpair failed"));
+ goto error;
+ }
+ virCommandTransferFD(cmd, sockets[1]);
+ if (qemuInvokeProxyHelper(def->emulator, sockets[0],
+ fs->src) < 0) {
+ VIR_FORCE_CLOSE(sockets[0]);
+ VIR_FORCE_CLOSE(sockets[1]);
+ goto error;
+ }
+ }
virCommandAddArg(cmd, "-fsdev");
- if (!(optstr = qemuBuildFSStr(fs, qemuCaps)))
+ if (!(optstr = qemuBuildFSStr(fs, qemuCaps, sockets[1])))
goto error;
virCommandAddArg(cmd, optstr);
VIR_FREE(optstr);
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index 3ccf4d7..5de7751 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -87,7 +87,8 @@ char *qemuBuildDriveStr(virConnectPtr conn,
bool bootable,
virBitmapPtr qemuCaps);
char *qemuBuildFSStr(virDomainFSDefPtr fs,
- virBitmapPtr qemuCaps);
+ virBitmapPtr qemuCaps,
+ int qemuSocket);
/* Current, best practice */
char * qemuBuildDriveDevStr(virDomainDefPtr def,
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index 012ba26..6485c5f 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -677,7 +677,8 @@ mymain(void)
QEMU_CAPS_FSDEV_WRITEOUT,
QEMU_CAPS_SCSI_BLOCK,
QEMU_CAPS_SCSI_CD,
- QEMU_CAPS_IDE_CD);
+ QEMU_CAPS_IDE_CD,
+ QEMU_CAPS_FSDEV_PROXY);
DO_TEST("qemu-1.1.0", 1001000, 0, 0,
QEMU_CAPS_VNC_COLON,
QEMU_CAPS_NO_REBOOT,
@@ -754,7 +755,8 @@ mymain(void)
QEMU_CAPS_IDE_CD,
QEMU_CAPS_NO_USER_CONFIG,
QEMU_CAPS_HDA_MICRO,
- QEMU_CAPS_NEC_USB_XHCI);
+ QEMU_CAPS_NEC_USB_XHCI,
+ QEMU_CAPS_FSDEV_PROXY);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
1.7.7.6
12 years, 3 months
[libvirt] [PATCH 0/3 v2] Add lsi and virtio-scsi qemu caps
by Guannan Ren
Add two capabilities flags for the model of scsi controller LSI and
virtio-scsi.
Use the lsilogic model by default, if current QEMU supports doesn't it,
raise an error.
When scsi model is given in XML explicitly, we try to check if
the underlying QEMU supports it or not, raise an error on checking
failure.
Guannan Ren(3)
qemu: add capabilities flags related to scsi controller
qemu: add two qemu caps for lsi and virtio-scsi SCSI
add lsi and virtio-scsi qemu caps in testcases.
src/qemu/qemu_capabilities.c | 7 +++
src/qemu/qemu_capabilities.h | 2 +
src/qemu/qemu_command.c | 106 +++++++++++++++++++++++++++++++----------
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_process.c | 9 ++-
tests/qemuhelptest.c | 10 +++-
tests/qemuxml2argvtest.c | 16 ++++--
7 files changed, 114 insertions(+), 39 deletions(-)
12 years, 3 months
[libvirt] [PATCH 1/5] add timeout seconds to qemuAgentSend()
by MATSUDA, Daiki
Add @seconds valuable to qemuAgentSend().
It points timeout seconds on @timeout true.
If @seconds is 0 on @timeout true, use default timeout value (QEMU_AGENT_WAIT_TIME).
If @timeout is false, @seconds is meanless.
qemu_agent.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 15af758..7699042 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -837,6 +837,7 @@ void qemuAgentClose(qemuAgentPtr mon)
* @mon: Monitor
* @msg: Message
* @timeout: use timeout?
+ * @seconds: timeout seconds. if 0 on @timeout true, use default value
*
* Send @msg to agent @mon.
* Wait max QEMU_AGENT_WAIT_TIME for agent
@@ -848,7 +849,8 @@ void qemuAgentClose(qemuAgentPtr mon)
*/
static int qemuAgentSend(qemuAgentPtr mon,
qemuAgentMessagePtr msg,
- bool timeout)
+ bool timeout,
+ int seconds)
{
int ret = -1;
unsigned long long now, then = 0;
@@ -864,7 +866,7 @@ static int qemuAgentSend(qemuAgentPtr mon,
if (timeout) {
if (virTimeMillisNow(&now) < 0)
return -1;
- then = now + QEMU_AGENT_WAIT_TIME;
+ then = now + (seconds == 0 ? QEMU_AGENT_WAIT_TIME : seconds * 1000);
}
mon->msg = msg;
@@ -937,7 +939,7 @@ qemuAgentGuestSync(qemuAgentPtr mon)
VIR_DEBUG("Sending guest-sync command with ID: %llu", id);
- send_ret = qemuAgentSend(mon, &sync_msg, true);
+ send_ret = qemuAgentSend(mon, &sync_msg, true, 0);
VIR_DEBUG("qemuAgentSend returned: %d", send_ret);
@@ -977,7 +979,8 @@ cleanup:
static int
qemuAgentCommand(qemuAgentPtr mon,
virJSONValuePtr cmd,
- virJSONValuePtr *reply)
+ virJSONValuePtr *reply,
+ int timeout)
{
int ret = -1;
qemuAgentMessage msg;
@@ -1005,7 +1008,7 @@ qemuAgentCommand(qemuAgentPtr mon,
VIR_DEBUG("Send command '%s' for write", cmdstr);
- ret = qemuAgentSend(mon, &msg, false);
+ ret = qemuAgentSend(mon, &msg, (timeout > 0 ? true : false), timeout);
VIR_DEBUG("Receive command reply ret=%d rxObject=%p",
ret, msg.rxObject);
@@ -1283,7 +1286,7 @@ int qemuAgentShutdown(qemuAgentPtr mon,
return -1;
mon->await_event = QEMU_AGENT_EVENT_SHUTDOWN;
- ret = qemuAgentCommand(mon, cmd, &reply);
+ ret = qemuAgentCommand(mon, cmd, &reply, 0);
if (reply && ret == 0)
ret = qemuAgentCheckError(cmd, reply);
@@ -1315,7 +1318,7 @@ int qemuAgentFSFreeze(qemuAgentPtr mon)
if (!cmd)
return -1;
- if (qemuAgentCommand(mon, cmd, &reply) < 0 ||
+ if (qemuAgentCommand(mon, cmd, &reply, 0) < 0 ||
qemuAgentCheckError(cmd, reply) < 0)
goto cleanup;
@@ -1352,7 +1355,7 @@ int qemuAgentFSThaw(qemuAgentPtr mon)
if (!cmd)
return -1;
- if (qemuAgentCommand(mon, cmd, &reply) < 0 ||
+ if (qemuAgentCommand(mon, cmd, &reply, 0) < 0 ||
qemuAgentCheckError(cmd, reply) < 0)
goto cleanup;
@@ -1389,7 +1392,7 @@ qemuAgentSuspend(qemuAgentPtr mon,
return -1;
mon->await_event = QEMU_AGENT_EVENT_SUSPEND;
- ret = qemuAgentCommand(mon, cmd, &reply);
+ ret = qemuAgentCommand(mon, cmd, &reply, 0);
if (reply && ret == 0)
ret = qemuAgentCheckError(cmd, reply);
12 years, 3 months