[libvirt] [RFC] [Patch] Support for Linux macvtap device
by Stefan Berger
Hello!
The attached patch provides support for the Linux macvtap device for
Qemu by passing a file descriptor to Qemu command line similar to how it
is done with a regular tap device. I have modified the network XML code
to understand a definition as the following one here:
<network>
<name>vepanet</name>
<uuid>4ebd5168-6321-4757-8397-f6e83484f402</uuid>
<extbridge mode='vepa' dev='eth0'/>
</network>
This XML indicates the device that links to the external bridge, here
eth0, and the mode this device is supposed to be set into, here 'vepa'.
If 'extbridge' is found in the XML, all other XML elements that have
been used so far, i.e., bridge, ip, dhcp, etc., are ignored.
The above network description can then be referenced from the virtual
machine definition using the typical interface description of type
'network':
<interface type='network'>
<source network='vepanet'/>
<model type='virtio'/>
</interface>
The above network XML holds the necessary parameters to open a macvtap
device. Using command line, one would issue the following command to
achieve the same what now libvirt does internally, using a patched
version of the 'ip' command:
ip link add link eth0 <optional name of if> type macvtap mode vepa
This then creates the network interface, i.e., macvtap12, along with
entries in /sys/class/net/macvtap12/ where the content of the ifindex
file returns the integer necessary to build the /dev/tap%d device to
open the file descriptor of and pass to qemu via command line argument.
Some details:
In libvirt I am first searching for an unused interface name following
the template macvtap%d unless the user has provided a name explicitly
or the previous macvtap%d is now taken by another VM. Once that has
succeeded, I follow the path through the filesystem to open the
corresponding /dev/tap%d.
Unlike the regular tap device, where the network interface disappears
once the corresponding file descriptor is closed, the macvtap device
needs explicit tear-down. So, when a VM terminates, I am deleting all
macvtap type interface with the MAC address as the interface of the
terminating VM.
Some further background on this device was recently given here:
https://www.redhat.com/archives/libvir-list/2010-January/msg00721.html
The macvtap patch for Linux was posted here:
http://lkml.org/lkml/2009/12/3/239
I'd be curious about comments on the code.
Signed-off-by: Stefan Berger <stefanb(a)us.ibm.com>
14 years, 9 months
[libvirt] [PATCH] qemu_monitor_json.c: avoid an unconditional leak
by Jim Meyering
Calling virJSONValueFree does not free the memory allocated via this:
cmd = qemuMonitorJSONMakeCommand("drive_add",
"s:pci_addr", dev,
"s:opts", drivestr,
NULL);
so I added the VIR_FREE:
>From 1d272e070b66fc16e2fcc23002879ee268a58a5f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 27 Jan 2010 09:58:12 +0100
Subject: [PATCH] qemu_monitor_json.c: avoid an unconditional leak
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONAttachDrive):
Don't leak the buffer behind a virJSONValuePtr.
---
src/qemu/qemu_monitor_json.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 8e88c7e..0f970bb 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1773,6 +1773,7 @@ int qemuMonitorJSONAttachDrive(qemuMonitorPtr mon,
ret = -1;
virJSONValueFree(cmd);
+ VIR_FREE(cmd);
virJSONValueFree(reply);
return ret;
}
--
1.7.0.rc0.140.gfbe7
14 years, 9 months
[libvirt] [PATCH] pci.c: correct erroneous expression
by Jim Meyering
An expression like this, can never be true, since the RHS is nonzero:
... !pciRead16(dev, PCI_CLASS_DEVICE) == PCI_CLASS_BRIDGE_PCI)
This appears to be what was intended:
pciRead16(dev, PCI_CLASS_DEVICE) != PCI_CLASS_BRIDGE_PCI)
>From a86de65c1da4f2cc9408465f6bc9ded481def47d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 26 Jan 2010 20:36:58 +0100
Subject: [PATCH] pci.c: correct erroneous expression
* src/util/pci.c (pciDeviceDownstreamLacksACS): Fix a typo
that rendered a subexpression always false.
---
src/util/pci.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/pci.c b/src/util/pci.c
index 09535bd..0274806 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2009-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -1266,7 +1266,7 @@ pciDeviceDownstreamLacksACS(virConnectPtr conn,
return -1;
pos = dev->pcie_cap_pos;
- if (!pos || !pciRead16(dev, PCI_CLASS_DEVICE) == PCI_CLASS_BRIDGE_PCI)
+ if (!pos || pciRead16(dev, PCI_CLASS_DEVICE) != PCI_CLASS_BRIDGE_PCI)
return 0;
flags = pciRead16(dev, pos + PCI_EXP_FLAGS);
--
1.7.0.rc0.140.gfbe7
14 years, 9 months
[libvirt] [PATCH] Don't call disabled timer callbacks in event-test.c
by Matthias Bolte
This fixes a segfault in the remote driver that occurs for example when
the event-test is run inside a domain-0 and libvirtd is also running.
---
examples/domain-events/events-c/event-test.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c
index b506687..b2eb1d5 100644
--- a/examples/domain-events/events-c/event-test.c
+++ b/examples/domain-events/events-c/event-test.c
@@ -335,9 +335,10 @@ int main(int argc, char **argv)
sts = poll(&pfd, 1, TIMEOUT_MS);
- /* We are assuming timeout of 0 here - so execute every time */
- if(t_cb && t_active)
+ /* if t_timeout < 0 then t_cb must not be called */
+ if (t_cb && t_active && t_timeout >= 0) {
t_cb(t_timeout,t_opaque);
+ }
if (sts == 0) {
/* DEBUG0("Poll timeout"); */
--
1.6.3.3
14 years, 9 months
[libvirt] [PATCH] esx: Output error details from libcurl
by Matthias Bolte
---
src/esx/esx_vi.c | 14 ++++++++------
src/esx/esx_vi.h | 1 +
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index 0fe9535..bc94326 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -251,8 +251,8 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url)
if (errorCode != CURLE_OK) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
- "curl_easy_perform() returned an error: %s (%d)",
- curl_easy_strerror(errorCode), errorCode);
+ "curl_easy_perform() returned an error: %s (%d) : %s",
+ curl_easy_strerror(errorCode), errorCode, ctx->curl_error);
return -1;
}
@@ -262,8 +262,8 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url)
if (errorCode != CURLE_OK) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"curl_easy_getinfo(CURLINFO_RESPONSE_CODE) returned an "
- "error: %s (%d)", curl_easy_strerror(errorCode),
- errorCode);
+ "error: %s (%d) : %s", curl_easy_strerror(errorCode),
+ errorCode, ctx->curl_error);
return -1;
}
@@ -282,8 +282,8 @@ esxVI_CURL_Perform(esxVI_Context *ctx, const char *url)
if (errorCode != CURLE_OK) {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"curl_easy_getinfo(CURLINFO_REDIRECT_URL) returned "
- "an error: %s (%d)", curl_easy_strerror(errorCode),
- errorCode);
+ "an error: %s (%d) : %s", curl_easy_strerror(errorCode),
+ errorCode, ctx->curl_error);
} else {
ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR,
"The server redirects from '%s' to '%s'", url,
@@ -360,6 +360,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url,
esxVI_CURL_ReadString);
curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEFUNCTION,
esxVI_CURL_WriteBuffer);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_ERRORBUFFER,
+ ctx->curl_error);
#if ESX_VI__CURL__ENABLE_DEBUG_OUTPUT
curl_easy_setopt(ctx->curl_handle, CURLOPT_DEBUGFUNCTION, esxVI_CURL_Debug);
curl_easy_setopt(ctx->curl_handle, CURLOPT_VERBOSE, 1);
diff --git a/src/esx/esx_vi.h b/src/esx/esx_vi.h
index 608dcbd..4e8b675 100644
--- a/src/esx/esx_vi.h
+++ b/src/esx/esx_vi.h
@@ -77,6 +77,7 @@ struct _esxVI_Context {
char *ipAddress;
CURL *curl_handle;
struct curl_slist *curl_headers;
+ char curl_error[CURL_ERROR_SIZE];
virMutex curl_lock;
char *username;
char *password;
--
1.6.3.3
14 years, 9 months
[libvirt] [PATCH] Add missing function parameter documentation
by Matthias Bolte
---
src/libvirt.c | 5 ++++-
src/util/virterror.c | 1 +
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index d973907..32f9fc4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10939,7 +10939,10 @@ error:
/**
* virConnectCompareCPU:
* @conn: virConnect connection
- * @xml: XML describing the CPU to compare with host CPU
+ * @xmlDesc: XML describing the CPU to compare with host CPU
+ * @flags: currently unused, pass 0
+ *
+ * Compares the given CPU description with the host CPU
*
* Returns comparison result according to enum virCPUCompareResult
*/
diff --git a/src/util/virterror.c b/src/util/virterror.c
index e2128b9..d72b307 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -291,6 +291,7 @@ virGetLastError(void)
/**
* virSetError:
+ * @newerr: previously saved error object
*
* Set the current error from a previously saved error object
*
--
1.6.3.3
14 years, 9 months
[libvirt] Potential segfault in udev driver
by Matthias Bolte
udevDeviceMonitorStartup registers udevEventHandleCallback as event
handle, but doesn't store the returned watch id to remove it later on.
Also it's not clear to me whether the event handle should be register
for the whole lifetime of the udev driver instance or just for the
udevEnumerateDevices call.
If for example the call to udevSetupSystemDev [1] fails
udevDeviceMonitorShutdown is called to cleanup, but
udevEventHandleCallback is still registered and may be called when
driverState is NULL again, resulting in a segfault in
udevEventHandleCallback.
So to solve this the udevEventHandleCallback event handle must be
removed at the appropriate place.
Maximilian Wilhelm found this problem.
[1] 22:42:20.960: error : udevSetupSystemDev:1460 : Failed to get udev
device for syspath '/sys/devices/virtual/dmi/id' or
'/sys/class/dmi/id'
Matthias
14 years, 9 months
[libvirt] [PATCH] Remove undefined symbols from libvirt_private.syms
by Matthias Bolte
---
src/libvirt_private.syms | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index e42c090..d56fb7d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -177,12 +177,10 @@ virDomainObjListInit;
virDomainObjListDeinit;
virDomainObjRef;
virDomainObjUnref;
-virDomainDeviceAddressEqual;
virDomainDevicePCIAddressEqual;
virDomainDeviceAddressIsValid;
virDomainDevicePCIAddressIsValid;
virDomainDeviceInfoIsSet;
-virDomainDeviceAddressClear;
virDomainControllerTypeToString;
virDomainControllerDefFree;
virDomainDeviceAddressTypeToString;
--
1.6.3.3
14 years, 9 months
[libvirt] [PATCH] udev: Set the state driver name
by Matthias Bolte
---
src/node_device/node_device_udev.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index a625d76..dcd889d 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1676,6 +1676,7 @@ static virDeviceMonitor udevDeviceMonitor = {
};
static virStateDriver udevStateDriver = {
+ .name = "udev",
.initialize = udevDeviceMonitorStartup,
.cleanup = udevDeviceMonitorShutdown,
.reload = udevDeviceMonitorReload,
--
1.6.3.3
14 years, 9 months
[libvirt] [Request]Backport live migration flags from 0.7.3 to 0.6.3?
by edison
Hi,
libvirt 0.7.3 adds the VIR_MIGRATE_PERSIST_DEST, VIR_MIGRATE_UNDEFINE_SOURCE
flags in migration, which are very useful in our product. Unfortunately, we
use libvirt 0.6.3.20, which is the default in RHEL 5.4. No such advanced
migration feature in this version.
I backported it for 0.6.3.20, in the attached patch. Do you think it's
possible to be merged into 0.6.3.20?:)
14 years, 9 months