Re: [libvirt] [PATCH 00/13] Add multiple trace backend function and add new ftrace backend for libvirt
by yangzy.fnst@cn.fujitsu.com
> [...]
> (For what it's worth, there are several different ways of executing systemtap
> scripts automatically at startup. There is an initscript.
> With the next version, its docs will move into 'man 8 systemtap', and grows a
> new 'onboot' option, to modules load even earlier at initramfs time via dracut.)
What 'onboot' option it is ?
BTW, do you mean that ftrace backend is not necessary for libvirt now?
Can it generate systemtap script automatically
and load the module on boot time without users operation?
We think adding multiple trace backends
can provide more trace interfaces for the upper tool which is based on libvirt.
Developer can chose more compatible trace scheme
according to the actual situation with more flexibility .
In the ways of usage by common user,
ftrace is more lightweight ,more compact and easier.
After all, writing systemTap script by users themselves
and making it as an initscript is not convenient for them.
Regards
Yang Zhiyong
> [...]
10 years, 9 months
[libvirt] uses of /etc/libvirt/<driver>/
by Jim Fehlig
I received a report about an odd use case of /etc/libvirt/<driver>/
config files, and would like to hear some opinions about it. The user
"preps" a host by mounting a remote fs containing VM images and config,
creates links in /etc/libvirt/<driver>/dom.xml to
/mnt-point/whatever/dom.xml, and starts libvirtd. All is well until
there is a need to modify the VM config (e.g. virsh setmaxmem ...
--config), at which point libvirt replaces the link with a file
containing the new config, instead of updating the contents of the
linked file.
I suppose I've always considered the contents of /etc/libvirt/<driver>/
private to libvirt, with a "modify at your own risk" warning, ignoring
that it is user configuration in /etc. What are the guidelines for
modifying the contents of these directories? Would the above be
considered valid use?
Regards,
Jim
10 years, 9 months
[libvirt] [PATCH python 0/2] Add unit test framework
by Daniel P. Berrange
The bug fix of Michal's to handling of typed parameters demonstrated
a clear need for a unit test framework for python bindings. By using
the test:///default driver we can easily test a great many python
APIs. Once the test driver has full API coverage, we can in fact unit
test all the python bindings.
The first patch does the bare minimum to plumb the unit test framework
into 'python setup test.py' (requires python-nose RPM to be present)
and does a test for the virConnectListAllDomains API.
The second patch tests Michal's previous bug fix - this test will fail
on current GIT and Michal's patch makes it pass.
A nice project for someone wanting to learn more about libvirt and the
python binding is to flesh out this test suite to cover as many APIs
as possible. We should aim to have an addition to this test suite
for any bugs we find in the bindings henceforth.
Daniel P. Berrange (2):
Add support for running unit tests with nose
Add test for setting scheduler parameters
setup.py | 5 +++++
tests/test_conn.py | 16 ++++++++++++++++
tests/test_domain.py | 19 +++++++++++++++++++
3 files changed, 40 insertions(+)
create mode 100644 tests/test_conn.py
create mode 100644 tests/test_domain.py
--
1.8.5.3
10 years, 9 months
[libvirt] [PATCH] cfg.mk: Fix whitespaces
by Martin Kletzander
Just to align the backslashes with most of the file.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
Pushed as 'trivial'.
cfg.mk | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index e75323e..319210b 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -893,9 +893,9 @@ sc_prohibit_wrong_filename_in_comment:
fi;
sc_prohibit_virConnectOpen_in_virsh:
- @prohibit='\bvirConnectOpen[a-zA-Z]* *\(' \
- in_vc_files='^tools/virsh-.*\.[ch]$$' \
- halt='Use vshConnect() in virsh instead of virConnectOpen*' \
+ @prohibit='\bvirConnectOpen[a-zA-Z]* *\(' \
+ in_vc_files='^tools/virsh-.*\.[ch]$$' \
+ halt='Use vshConnect() in virsh instead of virConnectOpen*' \
$(_sc_search_regexp)
--
1.9.0
10 years, 9 months
[libvirt] [PATCH] Remove double space in file name comment check
by Ján Tomko
Reported by Martin Kletzander
---
Pushed as trivial.
cfg.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cfg.mk b/cfg.mk
index a2fed11..e75323e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -888,7 +888,7 @@ sc_prohibit_wrong_filename_in_comment:
} \
}' $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') || fail=1; \
if test $$fail -eq 1; then \
- { echo '$(ME): The file name in comments must match the ' \
+ { echo '$(ME): The file name in comments must match the' \
'actual file name' 1>&2; exit 1; } \
fi;
--
1.8.3.2
10 years, 9 months
[libvirt] [PATCH 0/7] Various cleanups
by Martin Kletzander
Just getting rid of my local 'cleanup' branch. Some are trivial, but
every patch should be able to work on its own, I'm sending it in a
series not to mess up the list.
Martin Kletzander (7):
qemu: agent availability cleanup
tests: cleanup object-locking test
Fix inconsistency in using curly braces around functions
Don't leave empty first line in C source files
Explicitly cast some switch parameters to enum
Remove duplicate network model characters
Require spaces around equality comparisons
.gitignore | 6 +-
build-aux/bracket-spacing.pl | 9 +-
daemon/libvirtd-config.c | 5 +-
docs/internals/command.html.in | 3 +-
examples/dominfo/info1.c | 7 +-
src/conf/domain_conf.c | 30 ++--
src/conf/domain_nwfilter.c | 13 +-
src/conf/interface_conf.c | 54 ++++---
src/conf/nwfilter_conf.c | 21 ++-
src/conf/nwfilter_params.c | 3 +-
src/esx/esx_device_monitor.c | 1 -
src/esx/esx_device_monitor.h | 1 -
src/esx/esx_driver.c | 1 -
src/esx/esx_driver.h | 1 -
src/esx/esx_interface_driver.c | 1 -
src/esx/esx_interface_driver.h | 1 -
src/esx/esx_network_driver.c | 1 -
src/esx/esx_network_driver.h | 1 -
src/esx/esx_nwfilter_driver.c | 1 -
src/esx/esx_nwfilter_driver.h | 1 -
src/esx/esx_private.h | 1 -
src/esx/esx_secret_driver.c | 1 -
src/esx/esx_secret_driver.h | 1 -
src/esx/esx_storage_backend_iscsi.c | 1 -
src/esx/esx_storage_backend_iscsi.h | 1 -
src/esx/esx_storage_backend_vmfs.c | 1 -
src/esx/esx_storage_backend_vmfs.h | 1 -
src/esx/esx_storage_driver.c | 1 -
src/esx/esx_storage_driver.h | 1 -
src/esx/esx_util.c | 1 -
src/esx/esx_vi.c | 1 -
src/esx/esx_vi.h | 1 -
src/esx/esx_vi_methods.c | 1 -
src/esx/esx_vi_methods.h | 1 -
src/esx/esx_vi_types.c | 1 -
src/esx/esx_vi_types.h | 1 -
src/hyperv/hyperv_device_monitor.c | 1 -
src/hyperv/hyperv_device_monitor.h | 1 -
src/hyperv/hyperv_driver.c | 1 -
src/hyperv/hyperv_driver.h | 1 -
src/hyperv/hyperv_interface_driver.c | 1 -
src/hyperv/hyperv_interface_driver.h | 1 -
src/hyperv/hyperv_network_driver.c | 1 -
src/hyperv/hyperv_network_driver.h | 1 -
src/hyperv/hyperv_nwfilter_driver.c | 1 -
src/hyperv/hyperv_nwfilter_driver.h | 1 -
src/hyperv/hyperv_private.h | 1 -
src/hyperv/hyperv_secret_driver.c | 1 -
src/hyperv/hyperv_secret_driver.h | 1 -
src/hyperv/hyperv_storage_driver.c | 1 -
src/hyperv/hyperv_storage_driver.h | 1 -
src/hyperv/hyperv_util.c | 1 -
src/hyperv/hyperv_util.h | 1 -
src/hyperv/hyperv_wmi.c | 1 -
src/hyperv/hyperv_wmi.h | 1 -
src/hyperv/hyperv_wmi_classes.c | 1 -
src/hyperv/hyperv_wmi_classes.h | 1 -
src/hyperv/openwsman.h | 1 -
src/interface/interface_backend_netcf.c | 5 +-
src/libvirt.c | 2 +-
src/libxl/libxl_driver.c | 3 +-
src/locking/lock_driver_sanlock.c | 4 +-
src/lxc/lxc_driver.c | 27 ++--
src/network/bridge_driver.c | 45 ++++--
src/nwfilter/nwfilter_driver.c | 26 ++--
src/nwfilter/nwfilter_learnipaddr.c | 38 +++--
src/openvz/openvz_conf.c | 15 +-
src/openvz/openvz_driver.c | 42 ++++--
src/qemu/qemu_agent.c | 5 +-
src/qemu/qemu_command.c | 16 ++-
src/qemu/qemu_domain.c | 22 +++
src/qemu/qemu_domain.h | 4 +
src/qemu/qemu_driver.c | 193 +++++++++-----------------
src/qemu/qemu_migration.c | 4 +-
src/qemu/qemu_monitor.c | 3 +-
src/qemu/qemu_monitor_json.c | 3 +-
src/qemu/qemu_monitor_text.c | 17 ++-
src/rpc/virnetclient.c | 10 +-
src/rpc/virnetserver.c | 8 +-
src/rpc/virnetserverclient.c | 5 +-
src/rpc/virnettlscontext.c | 5 +-
src/secret/secret_driver.c | 8 +-
src/security/security_stack.c | 5 +-
src/security/virt-aa-helper.c | 1 -
src/storage/storage_backend_fs.c | 12 +-
src/storage/storage_driver.c | 72 ++++++----
src/test/test_driver.c | 135 ++++++++++++------
src/uml/uml_driver.c | 69 ++++++---
src/util/vircgroup.c | 12 +-
src/util/virconf.c | 5 +-
src/util/virdbus.c | 8 +-
src/util/virerror.c | 3 +-
src/util/vireventpoll.c | 20 ++-
src/util/virhook.c | 8 +-
src/util/virrandom.c | 5 +-
src/util/virsocketaddr.c | 26 ++--
src/util/virthread.c | 5 +-
src/util/virthreadpool.c | 3 +-
src/util/virutil.c | 17 ++-
src/util/viruuid.c | 5 +-
src/vbox/vbox_MSCOMGlue.c | 1 -
src/vbox/vbox_MSCOMGlue.h | 1 -
src/vbox/vbox_glue.c | 1 -
src/vbox/vbox_glue.h | 1 -
src/vbox/vbox_tmpl.c | 179 ++++++++++++++++--------
src/vmx/vmx.h | 1 -
src/xen/xen_driver.c | 6 +-
src/xen/xm_internal.c | 8 +-
src/xenapi/xenapi_driver.c | 4 +-
src/xenapi/xenapi_utils.c | 5 +-
src/xenxs/xen_xm.c | 32 +++--
tests/Makefile.am | 12 +-
tests/commandhelper.c | 5 +-
tests/commandtest.c | 2 +-
tests/domainsnapshotxml2xmltest.c | 2 +-
tests/interfacexml2xmltest.c | 2 +-
tests/libvirtdconftest.c | 4 +-
tests/lxcxml2xmltest.c | 2 +-
tests/networkxml2conftest.c | 2 +-
tests/networkxml2xmltest.c | 2 +-
tests/nodedevxml2xmltest.c | 2 +-
tests/nodeinfotest.c | 2 +-
tests/nwfilterxml2xmltest.c | 2 +-
tests/{object-locking.ml => objectlocking.ml} | 10 +-
tests/qemuargv2xmltest.c | 5 +-
tests/qemuxml2argvtest.c | 2 +-
tests/qemuxml2xmltest.c | 2 +-
tests/qemuxmlnstest.c | 2 +-
tests/sexpr2xmltest.c | 2 +-
tests/sockettest.c | 4 +-
tests/statstest.c | 2 +-
tests/storagepoolxml2xmltest.c | 2 +-
tests/storagevolxml2argvtest.c | 2 +-
tests/storagevolxml2xmltest.c | 2 +-
tests/testutils.c | 6 +-
tests/testutilslxc.h | 1 -
tests/testutilsxen.h | 1 -
tests/virauthconfigtest.c | 4 +-
tests/virbuftest.c | 2 +-
tests/vircgrouptest.c | 2 +-
tests/virdbustest.c | 4 +-
tests/virdrivermoduletest.c | 4 +-
tests/virhostdevtest.c | 2 +-
tests/viridentitytest.c | 4 +-
tests/virkeyfiletest.c | 4 +-
tests/virkmodtest.c | 2 +-
tests/virlockspacetest.c | 4 +-
tests/virnetmessagetest.c | 4 +-
tests/virnetsockettest.c | 2 +-
tests/virnettlscontexttest.c | 4 +-
tests/virnettlssessiontest.c | 4 +-
tests/virpcitest.c | 4 +-
tests/virportallocatortest.c | 2 +-
tests/virshtest.c | 56 +++++---
tests/virstringtest.c | 5 +-
tests/virsystemdtest.c | 4 +-
tests/virtimetest.c | 4 +-
tests/viruritest.c | 4 +-
tests/virusbtest.c | 3 +-
tests/xencapstest.c | 35 +++--
tests/xmconfigtest.c | 4 +-
tests/xml2sexprtest.c | 3 +-
tools/virsh-domain-monitor.c | 2 +-
tools/virsh-pool.c | 2 +-
164 files changed, 936 insertions(+), 679 deletions(-)
rename tests/{object-locking.ml => objectlocking.ml} (98%)
--
1.9.0
10 years, 9 months
[libvirt] [PATCH] virNetServerNewPostExecRestart: Initialize @max_anonymous_clients
by Michal Privoznik
Coverity spotted a use of possibly undefined variable. If a server is
restarting as an result of update, the JSON file that keeps current
value of some variables will not contain the new variables. This is
the case of @max_anonymous_clients too. We are correctly querying if
there's "max_anonymous_clients" in the JSON, however, we are not
setting a sane default if there's none.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/rpc/virnetserver.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index dfa3565..33a0346 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -494,12 +494,15 @@ virNetServerPtr virNetServerNewPostExecRestart(virJSONValuePtr object,
_("Missing max_clients data in JSON document"));
goto error;
}
- if (virJSONValueObjectHasKey(object, "max_anonymous_clients") &&
- virJSONValueObjectGetNumberUint(object, "max_anonymous_clients",
- &max_anonymous_clients) < 0) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Malformed max_anonymous_clients data in JSON document"));
- goto error;
+ if (virJSONValueObjectHasKey(object, "max_anonymous_clients")) {
+ if (virJSONValueObjectGetNumberUint(object, "max_anonymous_clients",
+ &max_anonymous_clients) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Malformed max_anonymous_clients data in JSON document"));
+ goto error;
+ }
+ } else {
+ max_anonymous_clients = max_clients;
}
if (virJSONValueObjectGetNumberUint(object, "keepaliveInterval", &keepaliveInterval) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
--
1.9.0
10 years, 9 months
[libvirt] [PATCH libvirt-python 1/2] setPyVirTypedParameter: Copy full field name
by Michal Privoznik
In the setPyVirTypedParameter we try to produce virTypedParameter
array from a pyhthon dictionary. However, when copying field name into
item in returned array, we use strncpy() as the field name is fixed
length array. To determine its size we use sizeof() but mistakenly
dereference it resulting in sizeof(char) which equals to 1 byte.
Moreover, there's no need for using sizeof() when we have a global
macro to tell us the length of the field name:
VIR_TYPED_PARAM_FIELD_LENGTH.
And since array is allocated using VIR_ALLOC() we are sure the memory
is initially filled with zeros. Hence, there's no need to terminate
string we've just copied into field name with '\0' character. It's
there for sure too as we copy up to field length - 1.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
libvirt-override.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index 83369fc..3765a43 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -197,8 +197,7 @@ setPyVirTypedParameter(PyObject *info,
goto cleanup;
}
- strncpy(temp->field, keystr, sizeof(*temp->field) - 1);
- temp->field[sizeof(*temp->field) - 1] = '\0';
+ strncpy(temp->field, keystr, VIR_TYPED_PARAM_FIELD_LENGTH - 1);
temp->type = params[i].type;
VIR_FREE(keystr);
--
1.9.0
10 years, 9 months
[libvirt] [PATCH] Fix memory leak in virDomainChrSourceDefClear()
by Nehal J Wani
While running qemuxml2xmltest, it was found that valgrind pointed out
the following memory leak:
==21905== 26 bytes in 1 blocks are definitely lost in loss record 23 of 69
==21905== at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==21905== by 0x3E782A754D: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
==21905== by 0x4CD986D: virDomainChrSourceDefParseXML (domain_conf.c:7233)
==21905== by 0x4CE4199: virDomainChrDefParseXML (domain_conf.c:7512)
==21905== by 0x4CFAF3F: virDomainDefParseXML (domain_conf.c:12303)
==21905== by 0x4CFB46E: virDomainDefParseNode (domain_conf.c:13031)
==21905== by 0x4CFB5E9: virDomainDefParse (domain_conf.c:12973)
==21905== by 0x41E9D8: testCompareXMLToXMLFiles (qemuxml2xmltest.c:40)
==21905== by 0x41EBAA: testCompareXMLToXMLHelper (qemuxml2xmltest.c:93)
==21905== by 0x421D21: virtTestRun (testutils.c:199)
==21905== by 0x41FCE9: mymain.part.0 (qemuxml2xmltest.c:244)
==21905== by 0x42249D: virtTestMain (testutils.c:782)
==21905==
... and 7 more
---
The leaks were specific to the tests:
DO_TEST("serial-spiceport");
DO_TEST("serial-spiceport-nospice");
src/conf/domain_conf.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 92b1324..f633db7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -1495,6 +1495,10 @@ virDomainChrSourceDefClear(virDomainChrSourceDefPtr def)
case VIR_DOMAIN_CHR_TYPE_UNIX:
VIR_FREE(def->data.nix.path);
break;
+
+ case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
+ VIR_FREE(def->data.spiceport.channel);
+ break;
}
}
--
1.7.1
10 years, 9 months
[libvirt] Python setInterfaceParameters function broken
by Brian Rak
I've been trying to use domain.setInterfaceParameters, and I'm finding
it's throwing the mysterious error:
libvirt.libvirtError: argument unsupported: parameter '' not supported
Enabling debug mode in libvirt reveals this:
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8001 : dom=0x7f2ecc0009b0, (VM:
name=SRVID8736, uuid=5121c1d6-19aa-4494-b6a7-09af270f24da),
device=vnet0, params=0x7f2ecc0011f0, nparams=6, flags=0
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8002 : params[""]=(uint)0
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8002 : params[""]=(uint)64000
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8002 : params[""]=(uint)10
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8002 : params[""]=(uint)64000
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8002 : params[""]=(uint)0
2014-03-17 18:41:33.780+0000: 16927: debug :
virDomainSetInterfaceParameters:8002 : params[""]=(uint)0
(irreverent lines trimmed)
Which ultimately led me to setPyVirTypedParameter lines 200-202. These
don't seem to work properly. I added some debugging:
strncpy(temp->field, keystr, sizeof(*temp->field) - 1);
temp->field[sizeof(*temp->field) - 1] = '\0';
DEBUG("current key name in: %s, out: %s field size: %i\n",
keystr, temp->field, sizeof(*temp->field) - 1);
temp->type = params[i].type;
which was displaying:
current key name in: outbound.peak, out: field size: 0
current key name in: inbound.peak, out: field size: 0
current key name in: inbound.burst, out: field size: 0
current key name in: inbound.average, out: field size: 0
current key name in: outbound.average, out: field size: 0
current key name in: outbound.burst, out: field size: 0
I am not good enough in C to determine what exactly the correct fix is
here. It seems like nothing that used this function could have ever
worked. My trivial patch was:
--- a/python27-libvirt/libvirt-python-1.2.2/libvirt-override.c
+++ b/python27-libvirt/libvirt-python-1.2.2/libvirt-override.c
@@ -197,8 +197,8 @@ setPyVirTypedParameter(PyObject *info,
goto cleanup;
}
- strncpy(temp->field, keystr, sizeof(*temp->field) - 1);
- temp->field[sizeof(*temp->field) - 1] = '\0';
+ strncpy(temp->field, keystr, VIR_TYPED_PARAM_FIELD_LENGTH - 1);
+ temp->field[VIR_TYPED_PARAM_FIELD_LENGTH - 1] = '\0';
temp->type = params[i].type;
VIR_FREE(keystr);
I am not sure if this is the best approach here. This change definitely
fixes the issue, and allows setInterfaceParameters to actually execute
successfully. I am not comfortable enough with my understanding of the
issue to actually submit this as a patch though. Is this something that
someone else can take a look at or fix?
My trivial test script that was showing the issue:
import libvirt
conn = libvirt.open(None)
if conn == None:
print 'Failed to connect';
sys.exit(1)
for id in conn.listDomainsID():
dom = conn.lookupByID(id)
if dom == None:
continue
params = dom.interfaceParameters('vnet0', 0)
print params
dom.setInterfaceParameters('vnet0', params, 0)
10 years, 9 months