[libvirt] [PATCH] dont't crash in virsh dominfo <domain>
by Guido Günther
Hi,
virsh dominfo domain crashes with:
#0 strlen () at ../sysdeps/i386/i486/strlen.S:69
#1 0x080891c9 in qemudNodeGetSecurityModel (conn=0x8133940, secmodel=0xb5676ede) at qemu/qemu_driver.c:4911
#2 0xb7eb5623 in virNodeGetSecurityModel (conn=0x8133940, secmodel=0x0) at libvirt.c:5118
#3 0x0806767a in remoteDispatchNodeGetSecurityModel (server=0x8118888, client=0x8134080, conn=0x8133940, hdr=0x81a8388, rerr=0xb56771d8, args=0xb56771a0, ret=0xb5677144) at remote.c:1306
#4 0x08068acc in remoteDispatchClientCall (server=0x8118888, client=0x8134080, msg=0x8168378) at dispatch.c:506
#5 0x08068ee3 in remoteDispatchClientRequest (server=0x8118888, client=0x8134080, msg=0x8168378) at dispatch.c:388
#6 0x0805baba in qemudWorker (data=0x811de2c) at libvirtd.c:1528
#7 0xb7bb8585 in start_thread (arg=0xb5677b70) at pthread_create.c:300
#8 0xb7b3a29e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
if there's no primary security driver set since we only intialize the
secmodel.model and secmodel.doi if we have one. Attached patch checks
for primarySecurityDriver instead of securityDriver since the later is
always set in qemudSecurityInit().
Cheers,
-- Guido
14 years, 8 months
[libvirt] [PATCH 1/14] Adding recursive locks
by Stefan Berger
This patch adds recursive locks necessary due to the processing of
network filter XML that can reference other network filters, including
references that cause looks. Loops in the XML are prevented but their
detection requires recursive locks.
14 years, 8 months
[libvirt] [PATCH v2 0/5] Introduce virDomainMigrateSetMaxDowntime API
by Jiri Denemark
This API call sets maximum tolerable time for which the domain is allowed to be
paused at the end of live migration. It's supposed to be called while the
domain is being live-migrated as a reaction to migration progress.
Changes in version 2:
- API renamed to reflect it's maximum downtime
- new flags parameter for the future
- qemu implementation was fixed so that the call is allowed iff the domain is
being migrated
- --downtime parameter of virsh migrate command was removed in favor of new
virsh migrate-setmaxdowntime which can be run independently
- virsh accepts downtime as nanoseconds instead of floating-point seconds
(shells don't deal with floating-point numbers well)
Jiri Denemark (5):
Public virDomainMigrateSetMaxDowntime API
Wire protocol and dispatcher for virDomainMigrateSetMaxDowntime
Implement virDomainMigrateSetMaxDowntime in remote driver
Implement virDomainMigrateSetMaxDowntime in qemu driver
Add migrate-setmaxdowntime command to virsh
daemon/remote.c | 29 ++++++++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 +++
daemon/remote_dispatch_table.h | 5 ++
include/libvirt/libvirt.h.in | 4 ++
src/libvirt.c | 49 +++++++++++++++++
src/libvirt_public.syms | 5 ++
src/qemu/qemu_driver.c | 70 ++++++++++++++++++++++++-
src/qemu/qemu_monitor.c | 15 +++++
src/qemu/qemu_monitor.h | 3 +
src/qemu/qemu_monitor_json.c | 29 ++++++++++
src/qemu/qemu_monitor_json.h | 3 +
src/qemu/qemu_monitor_text.c | 27 ++++++++++
src/qemu/qemu_monitor_text.h | 3 +
src/remote/remote_driver.c | 32 +++++++++++-
src/remote/remote_protocol.c | 13 +++++
src/remote/remote_protocol.h | 98 +++++++++++++++++++----------------
src/remote/remote_protocol.x | 10 +++-
tools/virsh.c | 66 +++++++++++++++++++++++
tools/virsh.pod | 6 ++
20 files changed, 429 insertions(+), 47 deletions(-)
14 years, 8 months
[libvirt] python binding: openAuth() segfaulting
by Dan Kenigsberg
I was trying to learn how to use openAuth(uri, auth_cb, flags), and
got:
Python 2.6.2 (r262:71600, Jan 25 2010, 18:46:47)
[GCC 4.4.2 20091222 (Red Hat 4.4.2-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> libvirt.openAuth('qemu:///system', lambda x: None, 0)
Segmentation fault (core dumped)
I guess my lambda expression was not what libvirt expected, but still..
Regards,
Dan.
14 years, 8 months
[libvirt] [PATCH Java] Cleanup close/free handling
by Matthias Bolte
The Connect class itself can have one ref to the internal virConnectPtr.
Therefore, it has to release the VCP in its close method always. Otherwise
multiple calls may release more then one ref, resulting in a ref-underflow
later on.
Make StoragePool's and StorageVol's free return int, like all other free
methods, to return the number of remaining refs.
Update Javadoc for all free methods to indicate that the return value is the
number of remaining refs and that a value >= is returned on success.
---
src/main/java/org/libvirt/Connect.java | 12 ++++--------
src/main/java/org/libvirt/Device.java | 2 +-
src/main/java/org/libvirt/Domain.java | 2 +-
src/main/java/org/libvirt/Interface.java | 2 +-
src/main/java/org/libvirt/Network.java | 1 +
src/main/java/org/libvirt/StoragePool.java | 14 +++++++++++---
src/main/java/org/libvirt/StorageVol.java | 12 +++++++++---
7 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/libvirt/Connect.java b/src/main/java/org/libvirt/Connect.java
index 3c6663e..8cec22e 100644
--- a/src/main/java/org/libvirt/Connect.java
+++ b/src/main/java/org/libvirt/Connect.java
@@ -219,7 +219,7 @@ public class Connect {
* the object after close() will result in an exception.
*
* @throws LibvirtException
- * @returns 0 for success, -1 for failure
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
public int close() throws LibvirtException {
int success = 0;
@@ -227,14 +227,10 @@ public class Connect {
success = libvirt.virConnectClose(VCP);
processError();
// If leave an invalid pointer dangling around JVM crashes and burns
- // if
- // someone tries to call a method on us
+ // if someone tries to call a method on us
// We rely on the underlying libvirt error handling to detect that
- // it's
- // called with a null virConnectPointer
- if (success == 0) {
- VCP = null;
- }
+ // it's called with a null virConnectPointer
+ VCP = null;
}
return success;
}
diff --git a/src/main/java/org/libvirt/Device.java b/src/main/java/org/libvirt/Device.java
index 26d8cbf..b4f9a0c 100644
--- a/src/main/java/org/libvirt/Device.java
+++ b/src/main/java/org/libvirt/Device.java
@@ -137,7 +137,7 @@ public class Device {
* structure is freed and should not be used thereafter.
*
* @throws LibvirtException
- * @returns 0 for success, -1 for failure.
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
public int free() throws LibvirtException {
int success = 0;
diff --git a/src/main/java/org/libvirt/Domain.java b/src/main/java/org/libvirt/Domain.java
index 8df928f..e7b24ef 100644
--- a/src/main/java/org/libvirt/Domain.java
+++ b/src/main/java/org/libvirt/Domain.java
@@ -167,7 +167,7 @@ public class Domain {
* structure is freed and should not be used thereafter.
*
* @throws LibvirtException
- * @returns 0 for success, -1 for failure.
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
public int free() throws LibvirtException {
int success = 0;
diff --git a/src/main/java/org/libvirt/Interface.java b/src/main/java/org/libvirt/Interface.java
index 0955cf9..44bcad5 100644
--- a/src/main/java/org/libvirt/Interface.java
+++ b/src/main/java/org/libvirt/Interface.java
@@ -117,7 +117,7 @@ public class Interface {
* structure is freed and should not be used thereafter.
*
* @throws LibvirtException
- * @returns 0 for success, -1 for failure.
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
public int free() throws LibvirtException {
int success = 0;
diff --git a/src/main/java/org/libvirt/Network.java b/src/main/java/org/libvirt/Network.java
index 14193fa..3c6f313 100644
--- a/src/main/java/org/libvirt/Network.java
+++ b/src/main/java/org/libvirt/Network.java
@@ -74,6 +74,7 @@ public class Network {
* return an error.
*
* @throws LibvirtException
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
public int free() throws LibvirtException {
int success = 0;
diff --git a/src/main/java/org/libvirt/StoragePool.java b/src/main/java/org/libvirt/StoragePool.java
index 3256601..7de7d50 100644
--- a/src/main/java/org/libvirt/StoragePool.java
+++ b/src/main/java/org/libvirt/StoragePool.java
@@ -118,10 +118,18 @@ public class StoragePool {
/**
* Free a storage pool object, releasing all memory associated with it. Does
* not change the state of the pool on the host.
+ *
+ * @throws LibvirtException
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
- public void free() throws LibvirtException {
- libvirt.virStoragePoolFree(VSPP);
- processError();
+ public int free() throws LibvirtException {
+ int success = 0;
+ if (VSPP != null) {
+ success = libvirt.virStoragePoolFree(VSPP);
+ processError();
+ VSPP = null;
+ }
+ return success;
}
/**
diff --git a/src/main/java/org/libvirt/StorageVol.java b/src/main/java/org/libvirt/StorageVol.java
index 9213813..5ae5f5c 100644
--- a/src/main/java/org/libvirt/StorageVol.java
+++ b/src/main/java/org/libvirt/StorageVol.java
@@ -80,10 +80,16 @@ public class StorageVol {
* to exist
*
* @throws LibvirtException
+ * @return number of references left (>= 0) for success, -1 for failure.
*/
- public void free() throws LibvirtException {
- libvirt.virStorageVolFree(VSVP);
- processError();
+ public int free() throws LibvirtException {
+ int success = 0;
+ if (VSVP != null) {
+ libvirt.virStorageVolFree(VSVP);
+ processError();
+ VSVP = null;
+ }
+ return success;
}
/**
--
1.6.3.3
14 years, 8 months
[libvirt] [PATCH 0/9] Rebased volume wiping API patches
by David Allan
Nobody ack'd (because of general lack of time, I hope) what I think is the final version of the volume wiping API patches, so here is the set again, rebased to the current head. I don't think there is anything controversial in here, as they incorporate all the feedback on previous versions.
Dave
David Allan (9):
Add public API for volume wiping
Define the internal driver API for vol wiping
Add vol wiping to ESX storage driver struct
Implement the public API for vol wiping
Define wire protocol format for vol wiping
Implement RPC client for vol wiping
Implement the remote dispatch bits of vol wiping
Simplified version of volume wiping based on feedback from the list.
Virsh support for vol wiping
daemon/remote.c | 32 +++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 ++
daemon/remote_dispatch_table.h | 5 +
include/libvirt/libvirt.h.in | 2 +
src/driver.h | 5 +
src/esx/esx_storage_driver.c | 1 +
src/libvirt.c | 47 ++++++++
src/libvirt_public.syms | 5 +
src/remote/remote_driver.c | 27 ++++
src/remote/remote_protocol.c | 11 ++
src/remote/remote_protocol.h | 9 ++
src/remote/remote_protocol.x | 8 +-
src/storage/storage_driver.c | 224 +++++++++++++++++++++++++++++++++++
tools/virsh.c | 42 +++++++
15 files changed, 426 insertions(+), 1 deletions(-)
14 years, 8 months
[libvirt] [PATCH] Support vhost-net mode at qemu startup for virtio network devices
by Laine Stump
* src/qemu/qemu_conf.h: add vhostfd to qemuBuildHostNetStr prototype
add qemudOpenVhostNet prototype
new flag to set when :,vhost=" found in qemu help
* src/qemu/qemu_conf.c: * set QEMUD_CMD_FLAG_VNET_HOST is ",vhost=" found
in qemu help
* qemudOpenVhostNet - opens /dev/vhost-net to pass
to qemu if everything is in place to use it.
* qemuBuildHostNetStr - add vhostfd to commandline
if it's not empty (higher levels decide whether
or not to fill it in)
* qemudBuildCommandLine - if /dev/vhost-net is
successfully opened, add its fd to tapfds array
so it isn't closed on qemu exec, and populate
vhostfd_name to be passed in to commandline
builder.
* src/qemu/qemu_driver.c: add filler 0 for new arg to qemuBuildHostNetStr,
along with a note that this must be implemented
in order for hot-plug of vhost-net virtio devices
to work properly (once qemu "netdev_add" monitor
command is implemented).
---
Note that these changes are a NOP until the bit of code checking for
"-netdev" in the qemu help and enabling QEMUD_CMD_FLAG_NETDEV in
(qemu_conf.c:qemudComputeCmdFlags()) is uncommented. You can already
do this by hand if you don't care about hot-plug/unplug of network
devices, but checking in that change needs to wait until the
netdev_add command is available in qemu (patches are
submitted/in-process of submission to upstream qemu for that).
src/qemu/qemu_conf.c | 55 +++++++++++++++++++++++++++++++++++++++++++----
src/qemu/qemu_conf.h | 8 ++++++-
src/qemu/qemu_driver.c | 3 +-
3 files changed, 59 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fb23c52..a2f610b 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1183,6 +1183,10 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
if (is_kvm && (version >= 10000 || kvm_version >= 74))
flags |= QEMUD_CMD_FLAG_VNET_HDR;
+ if (is_kvm && strstr(help, ",vhost=")) {
+ flags |= QEMUD_CMD_FLAG_VNET_HOST;
+ }
+
/*
* Handling of -incoming arg with varying features
* -incoming tcp (kvm >= 79, qemu >= 0.10.0)
@@ -1597,6 +1601,27 @@ cleanup:
}
+int
+qemudOpenVhostNet(virDomainNetDefPtr net,
+ unsigned long long qemuCmdFlags)
+{
+
+ /* If qemu supports vhost-net mode (including the -netdev command
+ * option), the nic model is virtio, and we can open
+ * /dev/vhost_net, assume that vhost-net mode is available and
+ * return the fd to /dev/vhost_net. Otherwise, return -1.
+ */
+
+ if (!(qemuCmdFlags & QEMUD_CMD_FLAG_VNET_HOST &&
+ qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV &&
+ qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE &&
+ net->model && STREQ(net->model, "virtio")))
+ return -1;
+
+ return open("/dev/vhost-net", O_RDWR, 0);
+}
+
+
static int qemuDomainDeviceAliasIndex(virDomainDeviceInfoPtr info,
const char *prefix)
{
@@ -2611,7 +2636,8 @@ char *
qemuBuildHostNetStr(virDomainNetDefPtr net,
char type_sep,
int vlan,
- const char *tapfd)
+ const char *tapfd,
+ const char *vhostfd)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -2680,6 +2706,10 @@ qemuBuildHostNetStr(virDomainNetDefPtr net,
type_sep, net->info.alias);
}
+ if (vhostfd && *vhostfd) {
+ virBufferVSprintf(&buf, ",vhost=on,vhostfd=%s", vhostfd);
+ }
+
if (virBufferError(&buf)) {
virBufferFreeAndReset(&buf);
virReportOOMError();
@@ -3828,6 +3858,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
virDomainNetDefPtr net = def->nets[i];
char *nic, *host;
char tapfd_name[50];
+ char vhostfd_name[50] = "";
int vlan;
/* VLANs are not used with -netdev, so don't record them */
@@ -3852,6 +3883,20 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (snprintf(tapfd_name, sizeof(tapfd_name), "%d", tapfd) >= sizeof(tapfd_name))
goto no_memory;
+
+ int vhostfd = qemudOpenVhostNet(net, qemuCmdFlags);
+ if (vhostfd >= 0) {
+ if (VIR_REALLOC_N(*tapfds, (*ntapfds)+1) < 0) {
+ close(tapfd);
+ close(vhostfd);
+ goto no_memory;
+ }
+
+ (*tapfds)[(*ntapfds)++] = vhostfd;
+ if (snprintf(vhostfd_name, sizeof(vhostfd_name), "%d", vhostfd)
+ >= sizeof(vhostfd_name))
+ goto no_memory;
+ }
} else if (net->type == VIR_DOMAIN_NET_TYPE_DIRECT) {
int tapfd = qemudPhysIfaceConnect(conn, driver, net,
net->data.direct.linkdev,
@@ -3882,8 +3927,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
if ((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE)) {
ADD_ARG_LIT("-netdev");
- if (!(host = qemuBuildHostNetStr(net, ',',
- vlan, tapfd_name)))
+ if (!(host = qemuBuildHostNetStr(net, ',', vlan,
+ tapfd_name, vhostfd_name)))
goto error;
ADD_ARG(host);
}
@@ -3901,8 +3946,8 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (!((qemuCmdFlags & QEMUD_CMD_FLAG_NETDEV) &&
(qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE))) {
ADD_ARG_LIT("-net");
- if (!(host = qemuBuildHostNetStr(net, ',',
- vlan, tapfd_name)))
+ if (!(host = qemuBuildHostNetStr(net, ',', vlan,
+ tapfd_name, vhostfd_name)))
goto error;
ADD_ARG(host);
}
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 6a9de5e..2d62cc4 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -83,6 +83,7 @@ enum qemud_cmd_flags {
QEMUD_CMD_FLAG_SMP_TOPOLOGY = (1 << 28), /* Is sockets=s,cores=c,threads=t available for -smp? */
QEMUD_CMD_FLAG_NETDEV = (1 << 29), /* The -netdev flag & netdev_add/remove monitor commands */
QEMUD_CMD_FLAG_RTC = (1 << 30), /* The -rtc flag for clock options */
+ QEMUD_CMD_FLAG_VNET_HOST = (1 << 31), /* vnet-host support is available in qemu */
};
/* Main driver state */
@@ -200,7 +201,8 @@ int qemudBuildCommandLine (virConnectPtr conn,
char * qemuBuildHostNetStr(virDomainNetDefPtr net,
char type_sep,
int vlan,
- const char *tapfd);
+ const char *tapfd,
+ const char *vhostfd);
/* Legacy, pre device support */
char * qemuBuildNicStr(virDomainNetDefPtr net,
@@ -252,6 +254,10 @@ int qemudNetworkIfaceConnect (virConnectPtr conn,
unsigned long long qemuCmdFlags)
ATTRIBUTE_NONNULL(1);
+int
+qemudOpenVhostNet(virDomainNetDefPtr net,
+ unsigned long long qemuCmdFlags);
+
int qemudPhysIfaceConnect(virConnectPtr conn,
struct qemud_driver *driver,
virDomainNetDefPtr net,
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c8f3a15..d08ee11 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6305,8 +6305,9 @@ static int qemudDomainAttachNetDevice(virConnectPtr conn,
qemuDomainObjExitMonitorWithDriver(driver, vm);
}
+ /* FIXME - need to support vhost-net here (5th arg) */
if (!(netstr = qemuBuildHostNetStr(net, ' ',
- vlan, tapfd_name)))
+ vlan, tapfd_name, 0)))
goto try_tapfd_close;
qemuDomainObjEnterMonitorWithDriver(driver, vm);
--
1.7.0.1
14 years, 8 months
[libvirt] Using callback under Windows compiling of libvirt library
by Dev.Atom
Hi,
I have compiled LibVirt 0.7.4 under mingw, and I want to use it with domain callback. Here is a a code sample of my situation (I'm using visual studio) :
static int domain_event(virConnectPtr conn,
virDomainPtr dom,
int evt,
int detail,
void *opaque)
{
bool test = true;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
virConnectPtr conn = virConnectOpen("qemu+tcp://192.168.220.198/session");
// Set Callback
int cbresult = virConnectDomainEventRegister(conn, domain_event, NULL, NULL);
// Lookup Domain
virDomainPtr dom = virDomainLookupByName(conn, "Test1");
if (virDomainIsActive(dom) == 1)
{
// Start Domain
int startDom = virDomainCreate(dom);
if (startDom != 0)
{
virErrorPtr e = virGetLastError();
bool test = true;
}
}
else
{
// Stop Domain
int StopDom = virDomainDestroy(dom);
if (StopDom != 0)
{
virErrorPtr e = virGetLastError();
bool test = true;
}
}
return 0;
}
This code works well when I did'nt use callbacks, but when I use it, it throw an error at the virDomainCreate or virDomainDestroy call. In the application windows (console) I have an "unmarshaling msg", I have study the case it comme from the call of "xdr_string" method in the "xdr_remote_nonull_string" method (remote_protocol.c).
I think, the xdr_string method is unable to marshall strings from the XDR* object to a char**.
I've tried with dynamic linking or static linking of libvirt lib. Have you any clue to have work callbacks ?
Best Regards,
Arnaud Champion
14 years, 8 months