[libvirt] [PATCH go-xml] add support for disk cache and io add support for controller model extend DomainAddress struct for PCI address and target&unit
by zhenwei.pi
---
domain.go | 13 +++++++++++--
domain_test.go | 31 ++++++++++++++++++++++++++++---
2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/domain.go b/domain.go
index 848835a..1382cd0 100644
--- a/domain.go
+++ b/domain.go
@@ -30,8 +30,10 @@ import (
)
type DomainController struct {
- Type string `xml:"type,attr"`
- Index string `xml:"index,attr"`
+ Type string `xml:"type,attr"`
+ Index string `xml:"index,attr"`
+ Model string `xml:"model,attr,omitempty"`
+ Address *DomainAddress `xml:"address"`
}
type DomainDiskSecret struct {
@@ -77,6 +79,8 @@ type DomainDisk struct {
Type string `xml:"type,attr"`
Device string `xml:"device,attr"`
Snapshot string `xml:"snapshot,attr,omitempty"`
+ Cache string `xml:"cache,attr,omitempty"`
+ Io string `xml:"io,attr,omitempty"`
Driver *DomainDiskDriver `xml:"driver"`
Auth *DomainDiskAuth `xml:"auth"`
Source *DomainDiskSource `xml:"source"`
@@ -196,8 +200,13 @@ type DomainAlias struct {
type DomainAddress struct {
Type string `xml:"type,attr"`
Controller *uint `xml:"controller,attr"`
+ Domain *uint `xml:"domain,attr"`
Bus *uint `xml:"bus,attr"`
Port *uint `xml:"port,attr"`
+ Slot *uint `xml:"slot,attr"`
+ Function *uint `xml:"function,attr"`
+ Target *uint `xml:"target,attr"`
+ Unit *uint `xml:"unit,attr"`
}
type DomainChardev struct {
diff --git a/domain_test.go b/domain_test.go
index 265cf80..fd6914e 100644
--- a/domain_test.go
+++ b/domain_test.go
@@ -130,10 +130,12 @@ var domainTestData = []struct {
},
},
DomainDisk{
- Type: "volume",
+ Type: "volume",
Device: "cdrom",
+ Cache: "none",
+ Io: "native",
Source: &DomainDiskSource{
- Pool: "default",
+ Pool: "default",
Volume: "myvolume",
},
Target: &DomainDiskTarget{
@@ -174,7 +176,7 @@ var domainTestData = []struct {
` </source>`,
` <target dev="vdd" bus="virtio"></target>`,
` </disk>`,
- ` <disk type="volume" device="cdrom">`,
+ ` <disk type="volume" device="cdrom" cache="none" io="native">`,
` <source pool="default" volume="myvolume"></source>`,
` <target dev="vde" bus="virtio"></target>`,
` </disk>`,
@@ -820,6 +822,29 @@ var domainTestData = []struct {
`</domain>`,
},
},
+ {
+ Object: &Domain{
+ Type: "kvm",
+ Name: "test",
+ Devices: &DomainDeviceList{
+ Controllers: []DomainController{
+ DomainController{
+ Type: "usb",
+ Index: "0",
+ Model: "piix3-uhci",
+ },
+ },
+ },
+ },
+ Expected: []string{
+ `<domain type="kvm">`,
+ ` <name>test</name>`,
+ ` <devices>`,
+ ` <controller type="usb" index="0" model="piix3-uhci"></controller>`,
+ ` </devices>`,
+ `</domain>`,
+ },
+ },
}
func TestDomain(t *testing.T) {
--
2.7.4
7 years, 6 months
[libvirt] Double deference error in libvirt_virConnectDomainEventRegisterAny
by fangying
Hi,
We'd like to report a double dereference error of 'pyobj_cbData' in libvirt_virConnectDomainEventRegisterAny.
The bug can be triggered in the situation where 'domainEventRegisterAny' (the python interface of libvirt_virConnectDomainEventRegisterAny)
is invoked and network connection is coincidently lost (likely libvirtd restarted) at same time.
We get the following stacktrace when the bug is hit.
Program terminated with signal 6, Aborted.
#0 0x00007fc45cba15d7 in raise () from /usr/lib64/libc.so.6
#1 0x00007fc45cba2cc8 in abort () from /usr/lib64/libc.so.6
#2 0x00007fc45cbe12f7 in __libc_message () from /usr/lib64/libc.so.6
#3 0x00007fc45cbe86d3 in _int_free () from /usr/lib64/libc.so.6
#4 0x00007fc45d8d292c in PyDict_Fini () from /usr/lib64/libpython2.7.so.1.0
#5 0x00007fc45d94f46a in Py_Finalize () from /usr/lib64/libpython2.7.so.1.0
#6 0x00007fc45d960735 in Py_Main () from /usr/lib64/libpython2.7.so.1.0
#7 0x00007fc45cb8daf5 in __libc_start_main () from /usr/lib64/libc.so.6
#8 0x0000000000400721 in _start ()
The double dereference of 'pyobj_cbData' is triggered in the following way:
(1) libvirt_virConnectDomainEventRegisterAny is invoked.
(2) the event is successfully added to the event callback list (virDomainEventStateRegisterClient in
remoteConnectDomainEventRegisterAny returns 1 which means ok).
(3) when function remoteConnectDomainEventRegisterAny is hit, network connection disconnected coincidently
(or libvirtd is restarted) in the context of function 'call' then the connection is lost and the
function 'call' failed, the branch virObjectEventStateDeregisterID is therefore taken.
(4) 'pyobj_conn' is dereferenced the 1st time in libvirt_virConnectDomainEventFreeFunc.
(5) 'pyobj_cbData' (refered to pyobj_conn) is dereferenced the 2nd time in libvirt_virConnectDomainEventRegisterAny.
(6) the double free error is triggered.
static void
libvirt_virConnectDomainEventFreeFunc(void *opaque)
{
PyObject *pyobj_conn = (PyObject*)opaque;
LIBVIRT_ENSURE_THREAD_STATE;
Py_DECREF(pyobj_conn); /* 1st dereference comes here */
LIBVIRT_RELEASE_THREAD_STATE;
}
static PyObject *
libvirt_virConnectDomainEventRegisterAny(PyObject *self ATTRIBUTE_UNUSED,
PyObject *args) {
...
Py_INCREF(pyobj_cbData);
LIBVIRT_BEGIN_ALLOW_THREADS;
ret = virConnectDomainEventRegisterAny(conn, dom, eventID,
cb, pyobj_cbData,
libvirt_virConnectDomainEventFreeFunc);
if (ret < 0) {
Py_DECREF(pyobj_cbData); /* 2nd dereference comes here */
}
}
Currently we cannot find a good solution to fix this problem, could anyone guide us to fix it ?
7 years, 6 months
[libvirt] [PATCH v2] rpc: Allow up to 256K records to be returned per domain from virConnectGetAllDomainStats.
by Richard W.M. Jones
The number of records that virConnectGetAllDomainStats can return per
domain is currently limited to 4096. This is quite low -- for
example, a single guest with ~320 disks will hit this limit. This
increases the limit to make it much larger. Note that
VIR_NET_MESSAGE_MAX still protects the total message size in the case
where there are many domains and many disks per domain.
I tested this using a guest with 500 disks with no issues.
Signed-off-by: Richard W.M. Jones <rjones(a)redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1440683
---
src/remote/remote_protocol.x | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 25e62a181..aa0aa38b6 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -233,7 +233,7 @@ const REMOTE_DOMAIN_FSFREEZE_MOUNTPOINTS_MAX = 256;
const REMOTE_NETWORK_DHCP_LEASES_MAX = 65536;
/* Upper limit on count of parameters returned via bulk stats API */
-const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 4096;
+const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 262144;
/* Upper limit of message size for tunable event. */
const REMOTE_DOMAIN_EVENT_TUNABLE_MAX = 2048;
--
2.13.0
7 years, 6 months
[libvirt] [PATCH] rpc: Allow up to 256K records to be returned from virConnectGetAllDomainStats.
by Richard W.M. Jones
In commit 89a706681cb3a4aa003d920db3163b809cfbc9ca, the returned
array of stats is limited to REMOTE_DOMAIN_LIST_MAX entries (4096).
As well as being far too low -- this breaks if a single guest is added
with 320 disks -- it also seems as if use of REMOTE_DOMAIN_LIST_MAX
was a mistake, and it should be using
REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX instead.
However REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX is also too low (also
4096), so this patch also increases the limit to something more
sensible, allowing us to cope with lots of stats from lots of domains
in future. (This limit could be increased further quite easily since
each stats record takes about 32 bytes, and the maximum message size
is currently 32 MB, so we could increase the limit by another factor
of 4 without touching the maximum message size).
I tested this using a guest with 320, 500 and 1000 disks with no issues.
Signed-off-by: Richard W.M. Jones <rjones(a)redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1440683
---
src/remote/remote_protocol.x | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 25e62a181..142508713 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -233,7 +233,7 @@ const REMOTE_DOMAIN_FSFREEZE_MOUNTPOINTS_MAX = 256;
const REMOTE_NETWORK_DHCP_LEASES_MAX = 65536;
/* Upper limit on count of parameters returned via bulk stats API */
-const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 4096;
+const REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX = 262144;
/* Upper limit of message size for tunable event. */
const REMOTE_DOMAIN_EVENT_TUNABLE_MAX = 2048;
@@ -3264,7 +3264,7 @@ struct remote_domain_event_callback_agent_lifecycle_msg {
};
struct remote_connect_get_all_domain_stats_ret {
- remote_domain_stats_record retStats<REMOTE_DOMAIN_LIST_MAX>;
+ remote_domain_stats_record retStats<REMOTE_CONNECT_GET_ALL_DOMAIN_STATS_MAX>;
};
struct remote_domain_fsinfo {
--
2.13.0
7 years, 6 months
[libvirt] [PATCH] rpc: Double buffer size instead of quadrupling buffer size.
by Richard W.M. Jones
When increasing the buffer size up to VIR_NET_MESSAGE_MAX, we
currently quadruple it each time. This unfortunately means that we
cannot allow certain buffer sizes -- for example the current
VIR_NET_MESSAGE_MAX == 33554432 can never be "hit" since ‘newlen’
jumps from 16MB to 64MB.
Instead of quadrupling, double it each time.
Thanks: Daniel Berrange.
---
src/rpc/virnetmessage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index c3a2e595c..5908b074a 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -358,7 +358,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
/* Try to encode the payload. If the buffer is too small increase it. */
while (!(*filter)(&xdr, data, 0)) {
- unsigned int newlen = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4;
+ unsigned int newlen = msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX;
+ newlen *= 2;
if (newlen > VIR_NET_MESSAGE_MAX) {
virReportError(VIR_ERR_RPC, "%s", _("Unable to encode message payload"));
--
2.13.0
7 years, 6 months
[libvirt] [PATCH] node: Don't return invalid pointers
by Peter Krempa
Commit 4337bc57be introduced code that would in certain error paths
unref the last reference of a pointer, but return it.
Clear the pointers before returning them
---
src/node_device/node_device_driver.c | 8 ++++++--
src/test/test_driver.c | 4 +++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index ba3da6288..3a6eeaaae 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -241,8 +241,10 @@ nodeDeviceLookupByName(virConnectPtr conn, const char *name)
goto cleanup;
if ((ret = virGetNodeDevice(conn, name))) {
- if (VIR_STRDUP(ret->parent, obj->def->parent) < 0)
+ if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) {
virObjectUnref(ret);
+ ret = NULL;
+ }
}
cleanup:
@@ -285,8 +287,10 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
goto out;
if ((dev = virGetNodeDevice(conn, obj->def->name))) {
- if (VIR_STRDUP(dev->parent, obj->def->parent) < 0)
+ if (VIR_STRDUP(dev->parent, obj->def->parent) < 0) {
virObjectUnref(dev);
+ dev = NULL;
+ }
}
virNodeDeviceObjUnlock(obj);
goto out;
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 2db3f7ddf..9330d9ea6 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -5331,8 +5331,10 @@ testNodeDeviceLookupByName(virConnectPtr conn, const char *name)
goto cleanup;
if ((ret = virGetNodeDevice(conn, name))) {
- if (VIR_STRDUP(ret->parent, obj->def->parent) < 0)
+ if (VIR_STRDUP(ret->parent, obj->def->parent) < 0) {
virObjectUnref(ret);
+ ret = NULL;
+ }
}
cleanup:
--
2.12.2
7 years, 6 months
[libvirt] [PATCH] node_device: fix memory leak in nodeDeviceSysfsGetSCSIHostCaps
by Yi Wang
The @tmp is allocated in virVHBAGetConfig in virVHBAIsVportCapable
condition, it will lost when virVHBAGetConfig called again.
Signed-off-by: Yi Wang <wang.yi59(a)zte.com.cn>
---
src/node_device/node_device_linux_sysfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/node_device/node_device_linux_sysfs.c b/src/node_device/node_device_linux_sysfs.c
index 1b7aa94..a9c7c9c 100644
--- a/src/node_device/node_device_linux_sysfs.c
+++ b/src/node_device/node_device_linux_sysfs.c
@@ -95,7 +95,8 @@ nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapSCSIHostPtr scsi_host)
goto cleanup;
}
- if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host,
+ VIR_FREE(tmp);
+ if (!(tmp = virVHBAGetConfig(NULL, scsi_host->host,
"npiv_vports_inuse"))) {
VIR_WARN("Failed to read npiv_vports_inuse for host%d",
scsi_host->host);
--
1.8.3.1
7 years, 6 months
[libvirt] [PATCH] util: fix memory leak in virSocketAddrFormatFull
by Yi Wang
The @ipv6_host allocated in virAsprintf may be lost when virAsprintf
addrstr failed.
Signed-off-by: Yi Wang <wang.yi59(a)zte.com.cn>
---
src/util/virsocketaddr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/util/virsocketaddr.c b/src/util/virsocketaddr.c
index 9dffbc7..95b5274 100644
--- a/src/util/virsocketaddr.c
+++ b/src/util/virsocketaddr.c
@@ -417,8 +417,10 @@ virSocketAddrFormatFull(const virSocketAddr *addr,
if (virAsprintf(&addrstr, "%s%s%s",
ipv6_host ? ipv6_host : host,
- separator ? separator : ":", port) == -1)
+ separator ? separator : ":", port) == -1) {
+ VIR_FREE(ipv6_host);
goto error;
+ }
VIR_FREE(ipv6_host);
} else {
--
1.8.3.1
7 years, 6 months
[libvirt] [PATCH 2/2] lxc: fixing wrong VIR_FREE after a return statement.
by Julio Faracco
There is a VIR_FREE after a return statement. That code section is never
executed and for this reason the "tty" variable is not being freed. This
commit rearrange the logic.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
src/lxc/lxc_container.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index a936342..af02b54 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1143,8 +1143,8 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
return -1;
if (virFileBindMountDevice(ttyPaths[i], tty) < 0) {
- return -1;
VIR_FREE(tty);
+ return -1;
}
VIR_FREE(tty);
--
1.8.3.1
7 years, 6 months
[libvirt] [PATCH 1/2] configure: fixing acl missing variable.
by Julio Faracco
This commit fixes an acl missing variable. The virt-acl.m4 inside the
macro directory does not contain the variable 'with_acl'. So, it is
being set as an empty string "with_acl=''". This is causing a missing
option during the configuration, even if you have acl libs installed.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
m4/virt-acl.m4 | 2 ++
1 file changed, 2 insertions(+)
diff --git a/m4/virt-acl.m4 b/m4/virt-acl.m4
index f7d1c6d..d548729 100644
--- a/m4/virt-acl.m4
+++ b/m4/virt-acl.m4
@@ -23,8 +23,10 @@ AC_DEFUN([LIBVIRT_CHECK_ACL], [
ACL_CFLAGS=""
ACL_LIBS=""
+ with_acl=no
if test "x$ac_cv_header_sys_acl_h:x$with_linux" = "xyes:xyes"; then
ACL_LIBS="-lacl"
+ with_acl=yes
fi
AC_SUBST([ACL_CFLAGS])
AC_SUBST([ACL_LIBS])
--
1.8.3.1
7 years, 6 months