[libvirt] RFC: Introduce API to query IP addresses for given domain
by Nehal J. Wani
Hello, fellow developers!
I am a GSoC candidate this year working for libvirt.org. My
project is "Introduce API to query IP addresses for given domain".
The discussion regarding this feature had started here:
http://www.mail-archive.com/libvir-list@redhat.com/msg51857.html and
then Michal had sent a patch too (refer:
http://www.mail-archive.com/libvir-list@redhat.com/msg57141.html). But
it was not pushed upstream due to lack of extensibility.
So far I've come up with an API and I want to get your opinion before
I start writing the rest so I don't follow the wrong direction.
Following are the valid commands:
domifaddr <domain-name>
domifaddr <domain-name> <interface-name>
domifaddr <domain-name> <interface-name> <method>
domifaddr <domain-name> <method>
methods:
(i) Querying qemu-guest-agent
(ii) Getting info from dnsmasq.leases file
(iii) Using the nwfilter to snoop the traffic
If no method is mentioned, qemu-guest-agent will be used.
Previous attempts by Michal had used structs and xml. Structs bring in
restrictions and xml has to be parsed. Hence I am not planning to
continue with either of these.
As a start, I would like to know your comments about my API which
queries the qemu-guest-agent and returns the results in
virTypedParameter **params.
Format(JSON) in which the qemu guest agent returns info:
[{"name":"lo",
"ip-addresses":
[{"ip-address-type":"ipv4","ip-address":"127.0.0.1","prefix":8},
{"ip-address-type":"ipv6","ip-address":"::1","prefix":128}],
"hardware-address":"00:00:00:00:00:00"},
{"name":"eth0",
"ip-addresses":
[{"ip-address-type":"ipv4","ip-address":"192.168.122.42","prefix":24},
{"ip-address-type":"ipv6","ip-address":"fe80::5054:ff:fe09:d240","prefix":64}],
"hardware-address":"52:54:00:09:d2:40"}]
//Possible 1-D Structure (A little hassle to maintain)
params[0] = {"iface-count",int,2}
params[1] = {"iface-name",string,"lo"}
params[2] = {"iface-hwaddr",string,"00:00:00:00:00:00"}
params[3] = {"iface-addr-count",int,2}
params[4] = {"iface-addr-type",string,"ipv4"}
params[5] = {"iface-addr",string,"127.0.0.1"}
params[6] = {"iface-addr-prefix",int,8}
params[7] = {"iface-addr-type",string,"ipv6"}
params[8] = {"iface-addr",string,"::1"}
params[9] = {"iface-addr-prefix",int,128}
....
....
....
//2D Structure: (Not very hasslefree, but easier to maintain as one
interface per row)
params[0] = {"iface-name",string,"lo"}{"iface-hwaddr",string,"00:00:00:00:00:00"}{"iface-addr-type",string,"ipv4"}{"iface-addr",string,"127.0.0.1"}{"iface-addr-prefix",int,8}{"iface-addr-type",string,"ipv6"}{"iface-addr",string,"::1"}{"iface-addr-prefix",int,128}
params[1] = {"iface-name",string,"eth0"}{"iface-hwaddr",string,"52:54:00:09:d2:40"}{"iface-addr-type",string,"ipv4"}{"iface-addr",string,"192.168.122.42"}{"iface-addr-prefix",int,8}{"iface-addr-type",string,"ipv6"}{"iface-addr",string,"fe80::5054:ff:fe09:d240"}{"iface-addr-prefix",int,64}
Function definitions that I intend to use are:
static int
remoteDispatchDomainInterfacesAddresses(
virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
remote_domain_interfaces_addresses_args *args,
remote_domain_interfaces_addresses_ret *ret)
int virDomainInterfacesAddresses (virDomainPtr dom,
virTypedParameterPtr *params,
int *nparams,
unsigned int flags);
typedef int
(*virDrvDomainInterfacesAddresses) (virDomainPtr dom,
virTypedParameterPtr *params,
int *nparams,
unsigned int flags);
int
virDomainInterfacesAddresses (virDomainPtr dom,
virTypedParameterPtr *params,
int *nparams,
unsigned int flags)
int
qemuAgentGetInterfaces(qemuAgentPtr mon,
virTypedParameterPtr *params,
int *nparams)
int qemuAgentGetInterfaces(qemuAgentPtr mon,
virTypedParameterPtr *params,
int *nparams);
static int
qemuDomainInterfacesAddresses(virDomainPtr dom,
virTypedParameterPtr *params,
int *nparams,
unsigned int flags)
static int
remoteDomainInterfacesAddresses(virDomainPtr dom,
virTypedParameterPtr *params,
int *nparams,
unsigned int flags)
static bool
cmdDomIfAddr(vshControl *ctl, const vshCmd *cmd)
Also, It will be helpful to know whether we want the client to first
query for the number of parameters and then send the request or have
the server side allocate appropriate memory and return the result once
in for all. In the latter case, I'll be using something of the kind
virTypedParameterPtr ***params.
Thanking You,
Nehal J. Wani
UG2, BTech CS+MS(CL)
IIIT-Hyderabad
http://commanlinewani.blogspot.com
11 years, 4 months
[libvirt] [libvirt-1.0.5]deadlock in child process after call function backtrace, any suggestions is appreciate!
by Caizhifeng
Hi ALL,
In order to catch the calltrace of deadlock in libvirtd, I modified the function virMutexLock as follows:
struct virMutex {
pthread_mutex_t lock;
void *trace[TRACE_SIZE]; //added for test
int ntrace; //added for test
};
void virMutexLock(virMutexPtr m)
{
struct timespec ts;
if (0 == clock_gettime(CLOCK_REALTIME, &ts)) {
ts.tv_sec += LOCK_TIMEOUT;
if (pthread_mutex_timedlock(&m->lock, &ts) == ETIMEDOUT) {
if (m->ntrace > 0)
virLogBacktrace(m->ntrace, m->trace);
pthread_mutex_lock(&m->lock);
}
m->ntrace = backtrace(m->trace, TRACE_SIZE); //record the call trace information.
} else {
pthread_mutex_lock(&m->lock);
}
}
The original is :
void virMutexLock(virMutexPtr m){
pthread_mutex_lock(&m->lock);
}
But, unfortunatly, sometimes, deadlock happened in child process after virFork, the father libvirtd process' pid is 2987, and the child libvirtd process id is 29509, which is forked in order to run a shell script.
root@cvk143:~# ps -ef | grep libvirtd
root 2987 1 52 08:36 ? 00:40:38 /usr/sbin/libvirtd -d
root 29509 2987 0 09:38 ? 00:00:00 /usr/sbin/libvirtd -d
root@cvk143:~#
the child process's call trace is as follow:
(gdb) bt
#0 0x00007f4d5e7fd89c in __lll_lock_wait () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007f4d5e7f9080 in _L_lock_903 () from /lib/x86_64-linux-gnu/libpthread.so.0
#2 0x00007f4d5e7f8f19 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#3 0x00007f4d5e5607db in dl_iterate_phdr () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007f4d5c3c88b6 in _Unwind_Find_FDE () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#5 0x00007f4d5c3c5d70 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#6 0x00007f4d5c3c6490 in ?? () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#7 0x00007f4d5c3c6d3e in _Unwind_Backtrace () from /lib/x86_64-linux-gnu/libgcc_s.so.1
#8 0x00007f4d5e53b1c8 in backtrace () from /lib/x86_64-linux-gnu/libc.so.6
#9 0x00007f4d5f6f8c92 in virMutexLock (m=0x7f4d5fadedc0) at util/virthreadpthread.c:128
#10 0x00007f4d5f6d0a3d in virLogLock () at util/virlog.c:152
#11 0x00007f4d5f6d0f66 in virLogReset () at util/virlog.c:311
#12 0x00007f4d5f6b3139 in virFork (pid=0x7f4d5a1a4310) at util/vircommand.c:281
#13 0x00007f4d5f6b3b06 in virExec (cmd=0x7f4d2000a6f0) at util/vircommand.c:493
#14 0x00007f4d5f6b8a34 in virCommandRunAsync (cmd=0x7f4d2000a6f0, pid=0x0) at util/vircommand.c:2340
#15 0x00007f4d5f6b815c in virCommandRun (cmd=0x7f4d2000a6f0, exitstatus=0x7f4d5a1a4728) at util/vircommand.c:2191
#16 0x00007f4d5f6b4bdd in virRun (argv=0x7f4d5a1a4730, status=0x7f4d5a1a4728) at util/vircommand.c:776
#17 0x00007f4d60231006 in virStorageNFSPoolCheckSub (hostName=0x7f4d50011630 "192.168.0.6", hostDir=0x7f4d50014560 "/vms/isos")
at storage/storage_backend.c:165
#18 0x00007f4d602312fa in virStoragePoolCheckFirst (pool=0x7f4d5000dcc0) at storage/storage_backend.c:255
#19 0x00007f4d602383af in virStorageBackendFileSystemRefresh (conn=0x7f4d3c0010a0, pool=0x7f4d5000dcc0) at storage/storage_backend_fs.c:887
#20 0x00007f4d6022c458 in storagePoolRefresh (obj=0x7f4d200012e0, flags=0) at storage/storage_driver.c:1705
#21 0x00007f4d5f7ac445 in virStoragePoolRefresh (pool=0x7f4d200012e0, flags=0) at libvirt.c:12936
#22 0x00007f4d6015c62f in remoteDispatchStoragePoolRefresh (server=0x7f4d60bb4ec0, client=0x7f4d60bbc380, msg=0x7f4d60bbcae0, rerr=0x7f4d5a1a4af0,
args=0x7f4d2000f0b0) at remote_dispatch.h:12867
#23 0x00007f4d6015c527 in remoteDispatchStoragePoolRefreshHelper (server=0x7f4d60bb4ec0, client=0x7f4d60bbc380, msg=0x7f4d60bbcae0, rerr=0x7f4d5a1a4af0,
args=0x7f4d2000f0b0, ret=0x7f4d200144f0) at remote_dispatch.h:12845
#24 0x00007f4d5f7fe7d5 in virNetServerProgramDispatchCall (prog=0x7f4d60bbfc90, server=0x7f4d60bb4ec0, client=0x7f4d60bbc380, msg=0x7f4d60bbcae0)
at rpc/virnetserverprogram.c:439
#25 0x00007f4d5f7fe34e in virNetServerProgramDispatch (prog=0x7f4d60bbfc90, server=0x7f4d60bb4ec0, client=0x7f4d60bbc380, msg=0x7f4d60bbcae0)
at rpc/virnetserverprogram.c:305
#26 0x00007f4d5f7f72ea in virNetServerProcessMsg (srv=0x7f4d60bb4ec0, client=0x7f4d60bbc380, prog=0x7f4d60bbfc90, msg=0x7f4d60bbcae0)
at rpc/virnetserver.c:162
#27 0x00007f4d5f7f73cd in virNetServerHandleJob (jobOpaque=0x7f4d60bbdbf0, opaque=0x7f4d60bb4ec0) at rpc/virnetserver.c:183
#28 0x00007f4d5f6f9602 in virThreadPoolWorker (opaque=0x7f4d60b9aa40) at util/virthreadpool.c:144
#29 0x00007f4d5f6f8fd6 in virThreadHelper (data=0x7f4d60b9a9b0) at util/virthreadpthread.c:212
#30 0x00007f4d5e7f6e9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#31 0x00007f4d5e5244bd in clone () from /lib/x86_64-linux-gnu/libc.so.6
#32 0x0000000000000000 in ?? ()
(gdb)
..............
I googled and found the similar deadlock call trace,which can be found in this link: code.google.com/p/gperftools/issues/detail?id=66 , but it is not a situation in libvirtd.
......
Labels: -Priority-Medium Priority-Low
Jan 22, 2013
#32 DarkAge...(a)gmail.com
Please note the glibc unwinder also uses dl_iterate_phdr, and takes several locks during backtrace generation in _Unwind_Find_FDE.
#0 0x00007ffff7bc6e80 in pthread_mutex_lock () from /lib/x86_64-linux-gnu/libpthread.so.0
#1 0x00007ffff7212fdb in dl_iterate_phdr () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff6be28b6 in _Unwind_Find_FDE () from /lib/libgcc_s.so.1
#3 0x00007ffff6bdfd70 in ?? () from /lib/libgcc_s.so.1
#4 0x00007ffff6be0d7d in _Unwind_Backtrace () from /lib/libgcc_s.so.1
#5 0x00007ffff71ed9c8 in backtrace () from /lib/x86_64-linux-gnu/libc.so.6
#6 0x000000000040fdb5 in glibc_backtrace (error=<synthetic pointer>, buffer=0x7fffffffdd10,
size=<optimized out>, ucontext=<optimized out>)
......
Is there anyone ever encouter the similar problem? Would be great if someone can help me on this.
Thank you very much.
-------------------------------------------------------------------------------------------------------------------------------------
本邮件及其附件含有杭州华三通信技术有限公司的保密信息,仅限于发送给上面地址中列出
的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、
或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本
邮件!
This e-mail and its attachments contain confidential information from H3C, which is
intended only for the person or entity whose address is listed above. Any use of the
information contained herein in any way (including, but not limited to, total or partial
disclosure, reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender
by phone or email immediately and delete it!
11 years, 4 months
[libvirt] attach-device error: XML error: unknown device type
by Chris Evich
Hi,
On Fedora 18 (libvirt 0.10.2.6-1) I'm trying to add a new serial device
to a KVM VM with:
virsh attach-device foobar /tmp/serial.xml
and I keep getting:
error: Failed to attach device from /tmp/serial.xml
error: XML error: unknown device type
with serial.xml:
<serial type='file'>
<source path='/tmp/serialfile'/>
<target port='1'/>
</serial>
Though I tried it w/o the <target> tag, with and without the --config
flag, and with and without the guest running. Assuming it's similar, I
tried and was successful in adding this device via virt-manager, though
it complains if the VM is running (which is fine).
What am I doing wrong with the virsh attach-device command or XML?
Thanks in advance.
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
11 years, 4 months
[libvirt] [PATCH v1 00/37] Remove virReportOOMError from almost everywhere
by Michal Privoznik
Make VIR_ALLOC, virAsprintf and friend to report OOM error and subsequently
adapt the code.
Patches available at:
git://gitorious.org/~zippy2/libvirt/michal-staging.git
branch oom1
Michal Privoznik (37):
viralloc: Report OOM error on failure
Introduce OOM reporting to virAsprintf
Adapt to VIR_ALLOC and virAsprintf in docs/
Adapt to VIR_ALLOC and virAsprintf in daemon/*
Adapt to VIR_ALLOC and virAsprintf in src/access/*
Adapt to VIR_ALLOC and virAsprintf in src/conf/*
Adapt to VIR_ALLOC and virAsprintf in src/cpu/*
Adapt to VIR_ALLOC and virAsprintf in src/esx/*
Adapt to VIR_ALLOC and virAsprintf in src/hyperv/*
Adapt to VIR_ALLOC and virAsprintf in src/interface/*
Adapt to VIR_ALLOC and virAsprintf in src/libxl/*
Adapt to VIR_ALLOC and virAsprintf in src/locking/*
Adapt to VIR_ALLOC and virAsprintf in src/lxc/*
Adapt to VIR_ALLOC and virAsprintf in src/node_device/*
Adapt to VIR_ALLOC and virAsprintf in src/network/*
Adapt to VIR_ALLOC and virAsprintf in src/nwfilter/*
Adapt to VIR_ALLOC and virAsprintf in src/openvz/*
Adapt to VIR_ALLOC and virAsprintf in src/parallels/*
Adapt to VIR_ALLOC and virAsprintf in src/phyp/*
Adapt to VIR_ALLOC and virAsprintf in src/qemu/*
Adapt to VIR_ALLOC and virAsprintf in src/remote/*
Adapt to VIR_ALLOC and virAsprintf in src/rpc/*
Adapt to VIR_ALLOC and virAsprintf in src/secret/*
Adapt to VIR_ALLOC and virAsprintf in src/security/*
Adapt to VIR_ALLOC and virAsprintf in src/storage/*
Adapt to VIR_ALLOC and virAsprintf in src/test/*
Adapt to VIR_ALLOC and virAsprintf in src/uml/*
Adapt to VIR_ALLOC and virAsprintf in src/util/*
Adapt to VIR_ALLOC and virAsprintf in src/vbox/*
Adapt to VIR_ALLOC and virAsprintf in src/vmware/*
Adapt to VIR_ALLOC and virAsprintf in src/vmx/*
Adapt to VIR_ALLOC and virAsprintf in src/xen/*
Adapt to VIR_ALLOC and virAsprintf in src/xenapi/*
Adapt to VIR_ALLOC and virAsprintf in src/xenxs/*
Adapt to VIR_ALLOC and virAsprintf in src/*
Adapt to VIR_ALLOC and virAsprintf in tests/*
Adapt to VIR_ALLOC and virAsprintf in tools/*
HACKING | 20 +-
cfg.mk | 2 +-
daemon/libvirtd-config.c | 12 +-
daemon/libvirtd.c | 24 +-
daemon/remote.c | 234 +++++---------------
daemon/stream.c | 4 +-
docs/hacking.html.in | 20 +-
po/POTFILES.in | 1 +
python/libvirt-override.c | 102 ++++-----
src/access/viraccessdriverpolkit.c | 4 +-
src/access/viraccessdriverstack.c | 4 +-
src/access/viraccessmanager.c | 4 +-
src/conf/cpu_conf.c | 34 +--
src/conf/domain_audit.c | 36 +--
src/conf/domain_conf.c | 337 +++++++++-------------------
src/conf/domain_event.c | 30 +--
src/conf/interface_conf.c | 35 +--
src/conf/netdev_bandwidth_conf.c | 12 +-
src/conf/netdev_vlan_conf.c | 4 +-
src/conf/netdev_vport_profile_conf.c | 4 +-
src/conf/network_conf.c | 120 +++-------
src/conf/node_device_conf.c | 29 +--
src/conf/nwfilter_conf.c | 33 +--
src/conf/nwfilter_ipaddrmap.c | 8 +-
src/conf/nwfilter_params.c | 35 +--
src/conf/secret_conf.c | 4 +-
src/conf/snapshot_conf.c | 47 ++--
src/conf/storage_conf.c | 38 +---
src/conf/storage_encryption_conf.c | 12 +-
src/conf/virchrdev.c | 12 +-
src/cpu/cpu.c | 4 +-
src/cpu/cpu_arm.c | 6 +-
src/cpu/cpu_generic.c | 12 +-
src/cpu/cpu_powerpc.c | 20 +-
src/cpu/cpu_s390.c | 4 +-
src/cpu/cpu_x86.c | 86 +++-----
src/driver.c | 4 +-
src/esx/esx_driver.c | 62 ++----
src/esx/esx_network_driver.c | 16 +-
src/esx/esx_storage_backend_iscsi.c | 4 +-
src/esx/esx_storage_backend_vmfs.c | 78 ++-----
src/esx/esx_util.c | 4 +-
src/esx/esx_vi.c | 50 ++---
src/esx/esx_vi.h | 3 +-
src/esx/esx_vi_types.c | 3 +-
src/fdstream.c | 4 +-
src/hyperv/hyperv_driver.c | 21 +-
src/hyperv/hyperv_util.c | 4 +-
src/hyperv/hyperv_wmi.c | 8 +-
src/interface/interface_backend_netcf.c | 19 +-
src/interface/interface_backend_udev.c | 33 +--
src/libvirt.c | 21 +-
src/libvirt_private.syms | 4 +-
src/libxl/libxl_conf.c | 18 +-
src/libxl/libxl_driver.c | 46 +---
src/locking/lock_daemon.c | 33 +--
src/locking/lock_daemon_config.c | 8 +-
src/locking/lock_driver_lockd.c | 23 +-
src/locking/lock_driver_sanlock.c | 28 +--
src/locking/lock_manager.c | 16 +-
src/lxc/lxc_cgroup.c | 4 +-
src/lxc/lxc_conf.c | 5 +-
src/lxc/lxc_container.c | 77 ++-----
src/lxc/lxc_controller.c | 50 +----
src/lxc/lxc_driver.c | 92 ++------
src/lxc/lxc_fuse.c | 12 +-
src/lxc/lxc_monitor.c | 4 +-
src/lxc/lxc_process.c | 32 +--
src/network/bridge_driver.c | 138 ++++--------
src/node_device/node_device_driver.c | 4 +-
src/node_device/node_device_udev.c | 18 +-
src/nodeinfo.c | 58 ++---
src/nwfilter/nwfilter_dhcpsnoop.c | 29 +--
src/nwfilter/nwfilter_driver.c | 13 +-
src/nwfilter/nwfilter_ebiptables_driver.c | 46 ++--
src/nwfilter/nwfilter_gentech_driver.c | 24 +-
src/nwfilter/nwfilter_learnipaddr.c | 12 +-
src/openvz/openvz_conf.c | 42 ++--
src/openvz/openvz_driver.c | 10 +-
src/parallels/parallels_driver.c | 65 ++----
src/parallels/parallels_network.c | 24 +-
src/parallels/parallels_storage.c | 50 ++---
src/parallels/parallels_utils.c | 4 +-
src/phyp/phyp_driver.c | 95 ++------
src/qemu/qemu_agent.c | 42 ++--
src/qemu/qemu_capabilities.c | 69 ++----
src/qemu/qemu_cgroup.c | 4 +-
src/qemu/qemu_command.c | 355 ++++++++++--------------------
src/qemu/qemu_conf.c | 88 +++-----
src/qemu/qemu_domain.c | 50 ++---
src/qemu/qemu_driver.c | 124 +++--------
src/qemu/qemu_hotplug.c | 84 ++-----
src/qemu/qemu_migration.c | 94 +++-----
src/qemu/qemu_monitor.c | 33 +--
src/qemu/qemu_monitor_json.c | 118 +++-------
src/qemu/qemu_monitor_text.c | 233 +++++---------------
src/qemu/qemu_process.c | 70 ++----
src/remote/remote_driver.c | 107 +++------
src/rpc/gendispatch.pl | 8 +-
src/rpc/virnetclient.c | 26 +--
src/rpc/virnetclientprogram.c | 12 +-
src/rpc/virnetclientstream.c | 4 +-
src/rpc/virnetmessage.c | 24 +-
src/rpc/virnetserver.c | 23 +-
src/rpc/virnetserverclient.c | 19 +-
src/rpc/virnetservermdns.c | 20 +-
src/rpc/virnetserverprogram.c | 8 +-
src/rpc/virnetserverservice.c | 12 +-
src/rpc/virnetsocket.c | 8 +-
src/rpc/virnetsshsession.c | 21 +-
src/rpc/virnettlscontext.c | 26 +--
src/secret/secret_driver.c | 49 +----
src/security/security_apparmor.c | 25 +--
src/security/security_dac.c | 12 +-
src/security/security_manager.c | 12 +-
src/security/security_selinux.c | 45 ++--
src/security/security_stack.c | 8 +-
src/storage/storage_backend.c | 35 +--
src/storage/storage_backend_disk.c | 17 +-
src/storage/storage_backend_fs.c | 31 +--
src/storage/storage_backend_iscsi.c | 27 +--
src/storage/storage_backend_logical.c | 48 +---
src/storage/storage_backend_mpath.c | 20 +-
src/storage/storage_backend_rbd.c | 18 +-
src/storage/storage_backend_scsi.c | 21 +-
src/storage/storage_backend_sheepdog.c | 4 +-
src/storage/storage_driver.c | 23 +-
src/test/test_driver.c | 91 +++-----
src/uml/uml_conf.c | 28 +--
src/uml/uml_driver.c | 36 +--
src/util/iohelper.c | 4 +-
src/util/viralloc.c | 165 ++++++++++++--
src/util/viralloc.h | 213 ++++++++++++++----
src/util/virauth.c | 6 +-
src/util/virauthconfig.c | 16 +-
src/util/virbuffer.c | 8 +-
src/util/vircgroup.c | 13 +-
src/util/vircommand.c | 13 +-
src/util/virconf.c | 10 +-
src/util/virdnsmasq.c | 53 ++---
src/util/virerror.c | 6 +-
src/util/vireventpoll.c | 4 +-
src/util/virfile.c | 34 +--
src/util/virhash.c | 11 +-
src/util/viridentity.c | 4 +-
src/util/virinitctl.c | 4 +-
src/util/viriptables.c | 11 +-
src/util/virkeyfile.c | 4 +-
src/util/virlockspace.c | 37 +---
src/util/virlog.c | 2 +-
src/util/virnetdev.c | 45 +---
src/util/virnetdevbandwidth.c | 21 +-
src/util/virnetdevbridge.c | 8 +-
src/util/virnetdevmacvlan.c | 6 +-
src/util/virnetdevopenvswitch.c | 18 +-
src/util/virnetdevtap.c | 8 +-
src/util/virnetdevveth.c | 8 +-
src/util/virnetdevvlan.c | 4 +-
src/util/virnetdevvportprofile.c | 4 +-
src/util/virnetlink.c | 8 +-
src/util/virobject.c | 8 +-
src/util/virpci.c | 96 ++------
src/util/virportallocator.c | 1 -
src/util/virprocess.c | 17 +-
src/util/virrandom.c | 9 +-
src/util/virscsi.c | 28 +--
src/util/virsexpr.c | 4 +-
src/util/virsocketaddr.c | 6 +-
src/util/virstoragefile.c | 32 +--
src/util/virstring.c | 44 ++--
src/util/virstring.h | 67 +++++-
src/util/virsysinfo.c | 22 +-
src/util/virthreadpool.c | 21 +-
src/util/virthreadpthread.c | 2 +-
src/util/virtime.c | 8 +-
src/util/virtpm.c | 4 +-
src/util/virtypedparam.c | 68 ++----
src/util/viruri.c | 12 +-
src/util/virusb.c | 13 +-
src/util/virutil.c | 107 +++------
src/util/virxml.c | 1 -
src/vbox/vbox_MSCOMGlue.c | 8 +-
src/vbox/vbox_XPCOMCGlue.c | 4 +-
src/vbox/vbox_tmpl.c | 126 +++--------
src/vmware/vmware_conf.c | 33 +--
src/vmware/vmware_driver.c | 4 +-
src/vmx/vmx.c | 92 ++------
src/xen/block_stats.c | 8 +-
src/xen/xen_driver.c | 42 +---
src/xen/xen_hypervisor.c | 17 +-
src/xen/xen_inotify.c | 4 +-
src/xen/xend_internal.c | 38 +---
src/xen/xm_internal.c | 24 +-
src/xen/xs_internal.c | 24 +-
src/xenapi/xenapi_driver.c | 29 +--
src/xenapi/xenapi_utils.c | 11 +-
src/xenxs/xen_sxpr.c | 112 ++++------
src/xenxs/xen_xm.c | 204 ++++++++---------
tests/commandhelper.c | 1 +
tests/commandtest.c | 8 +-
tests/domainsnapshotxml2xmltest.c | 2 +
tests/fchosttest.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/qemuargv2xmltest.c | 2 +
tests/qemuhelptest.c | 2 +
tests/qemumonitortestutils.c | 17 +-
tests/qemuxml2xmltest.c | 2 +
tests/securityselinuxlabeltest.c | 21 +-
tests/securityselinuxtest.c | 8 +-
tests/sexpr2xmltest.c | 2 +
tests/storagepoolxml2xmltest.c | 2 +
tests/storagevolxml2argvtest.c | 2 +
tests/storagevolxml2xmltest.c | 2 +
tests/sysinfotest.c | 2 +
tests/test_conf.c | 2 +-
tests/virbuftest.c | 2 +
tests/virhashtest.c | 2 +
tests/virnetmessagetest.c | 20 +-
tests/virshtest.c | 2 +
tests/virstoragetest.c | 5 +-
tests/xencapstest.c | 2 +
tests/xmconfigtest.c | 2 +
tests/xml2sexprtest.c | 2 +
tools/console.c | 6 +-
tools/virsh-domain-monitor.c | 4 +-
tools/virsh-domain.c | 28 +--
tools/virsh.c | 1 -
tools/virt-host-validate-common.c | 2 +
235 files changed, 2373 insertions(+), 4941 deletions(-)
--
1.8.1.5
11 years, 4 months
[libvirt] [PATCH] Resolve Coverity complaints in tests/securityselinuxlabeltest.c
by John Ferlan
Two complaints of RESOURCE_FREE due to going to cleanup prior to a
VIR_FREE(line). Two complaints of FORWARD_NULL due to 'tmp' being
accessed after a strchr() without first checking if the return was NULL.
While looking at the code it seems that 'line' need only be allocated
once as the while loop will keep reading into line until eof causing
an unreported leak since line was never VIR_FREE()'d at the bottom of
the loop.
---
tests/securityselinuxlabeltest.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c
index 5ae4f57..d2ba49b 100644
--- a/tests/securityselinuxlabeltest.c
+++ b/tests/securityselinuxlabeltest.c
@@ -79,6 +79,7 @@ testSELinuxLoadFileList(const char *testname,
int ret = -1;
char *path = NULL;
FILE *fp = NULL;
+ char *line = NULL;
*files = NULL;
*nfiles = 0;
@@ -93,37 +94,43 @@ testSELinuxLoadFileList(const char *testname,
goto cleanup;
}
+ if (VIR_ALLOC_N(line, 1024) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
while (!feof(fp)) {
- char *line;
- char *file, *context;
- if (VIR_ALLOC_N(line, 1024) < 0) {
- virReportOOMError();
- goto cleanup;
- }
+ char *file, *context, *tmp;
if (!fgets(line, 1024, fp)) {
if (!feof(fp))
goto cleanup;
break;
}
- char *tmp = strchr(line, ';');
+ tmp = strchr(line, ';');
+ if (!tmp) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "unexpected format for line '%s'",
+ line);
+ goto cleanup;
+ }
*tmp = '\0';
tmp++;
- if (virAsprintf(&file, "%s/securityselinuxlabeldata%s", abs_builddir, line) < 0) {
- VIR_FREE(line);
+ if (virAsprintf(&file, "%s/securityselinuxlabeldata%s",
+ abs_builddir, line) < 0) {
virReportOOMError();
goto cleanup;
}
if (*tmp != '\0' && *tmp != '\n') {
if (VIR_STRDUP(context, tmp) < 0) {
- VIR_FREE(line);
VIR_FREE(file);
goto cleanup;
}
tmp = strchr(context, '\n');
- *tmp = '\0';
+ if (tmp)
+ *tmp = '\0';
} else {
context = NULL;
}
@@ -142,6 +149,7 @@ testSELinuxLoadFileList(const char *testname,
cleanup:
VIR_FORCE_FCLOSE(fp);
VIR_FREE(path);
+ VIR_FREE(line);
return ret;
}
--
1.8.1.4
11 years, 4 months
[libvirt] [PATCH 0/3] qemu: Make setting memory limits consistent
by Jiri Denemark
We need to set memory limits in several cases:
- when setting hard_limit in memory cgroup
- when starting a domain with a VFIO PCI device attached
- when hotplugging a VFIO PCI device
- when memoryBacking/locked is used
This series makes use of a shared code to compute the limits in all of
those cases.
Jiri Denemark (3):
qemu: Move memory limit computation to a reusable function
qemu: Use qemuDomainMemoryLimit when computing memory for VFIO
qemu: Set RLIMIT_MEMLOCK when memoryBacking/locked is used
src/qemu/qemu_cgroup.c | 21 ++-------------------
src/qemu/qemu_command.c | 18 ++++++++----------
src/qemu/qemu_domain.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_domain.h | 2 ++
src/qemu/qemu_hotplug.c | 18 ++++++++----------
5 files changed, 65 insertions(+), 39 deletions(-)
--
1.8.2.1
11 years, 4 months
[libvirt] [PATCH] Don't spam logs with "port 0 must be in range" errors
by Jiri Denemark
Whenever virPortAllocatorRelease is called with port == 0, it complains
that the port is not in an allowed range, which is expectable as the
port was never allocated. Let's make virPortAllocatorRelease ignore 0
ports in a similar way free() ignores NULL pointers.
---
src/qemu/qemu_migration.c | 4 ++--
src/qemu/qemu_process.c | 27 +++++++++++----------------
src/util/virportallocator.c | 4 ++++
3 files changed, 17 insertions(+), 18 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 6b488ca..a6b7acb 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1159,7 +1159,7 @@ qemuMigrationStartNBDServer(virQEMUDriverPtr driver,
cleanup:
VIR_FREE(diskAlias);
- if ((ret < 0) && port)
+ if (ret < 0)
virPortAllocatorRelease(driver->remotePorts, port);
return ret;
}
@@ -2448,7 +2448,7 @@ cleanup:
virObjectUnlock(vm);
else
qemuDomainRemoveInactive(driver, vm);
- if (ret < 0 && priv->nbdPort) {
+ if (ret < 0) {
virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
priv->nbdPort = 0;
}
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 114e885..f8c652f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3368,8 +3368,7 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
return 0;
error:
- if (port)
- virPortAllocatorRelease(driver->remotePorts, port);
+ virPortAllocatorRelease(driver->remotePorts, port);
return -1;
}
@@ -4093,10 +4092,8 @@ void qemuProcessStop(virQEMUDriverPtr driver,
}
}
- if (priv->nbdPort) {
- virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
- priv->nbdPort = 0;
- }
+ virPortAllocatorRelease(driver->remotePorts, priv->nbdPort);
+ priv->nbdPort = 0;
if (priv->agent) {
qemuAgentClose(priv->agent);
@@ -4217,20 +4214,18 @@ retry:
virDomainGraphicsDefPtr graphics = vm->def->graphics[i];
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC) {
if (graphics->data.vnc.autoport) {
- ignore_value(virPortAllocatorRelease(driver->remotePorts,
- graphics->data.vnc.port));
- }
- if (graphics->data.vnc.websocket) {
- ignore_value(virPortAllocatorRelease(driver->webSocketPorts,
- graphics->data.vnc.websocket));
+ virPortAllocatorRelease(driver->remotePorts,
+ graphics->data.vnc.port);
}
+ virPortAllocatorRelease(driver->webSocketPorts,
+ graphics->data.vnc.websocket);
}
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
graphics->data.spice.autoport) {
- ignore_value(virPortAllocatorRelease(driver->remotePorts,
- graphics->data.spice.port));
- ignore_value(virPortAllocatorRelease(driver->remotePorts,
- graphics->data.spice.tlsPort));
+ virPortAllocatorRelease(driver->remotePorts,
+ graphics->data.spice.port);
+ virPortAllocatorRelease(driver->remotePorts,
+ graphics->data.spice.tlsPort);
}
}
diff --git a/src/util/virportallocator.c b/src/util/virportallocator.c
index c7be10f..0757966 100644
--- a/src/util/virportallocator.c
+++ b/src/util/virportallocator.c
@@ -166,6 +166,10 @@ int virPortAllocatorRelease(virPortAllocatorPtr pa,
unsigned short port)
{
int ret = -1;
+
+ if (!port)
+ return 0;
+
virObjectLock(pa);
if (port < pa->start ||
--
1.8.2.1
11 years, 4 months
[libvirt] [PATCH] qemu: Release correct websocket port
by Jiri Denemark
---
src/qemu/qemu_process.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index df0ac72..114e885 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -4222,7 +4222,7 @@ retry:
}
if (graphics->data.vnc.websocket) {
ignore_value(virPortAllocatorRelease(driver->webSocketPorts,
- graphics->data.vnc.port));
+ graphics->data.vnc.websocket));
}
}
if (graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
--
1.8.2.1
11 years, 4 months
[libvirt] [PATCH] Paused domain should remain paused after migration
by Jiri Denemark
https://bugzilla.redhat.com/show_bug.cgi?id=981139
If a domain is paused before migration starts, we need to tell that to
the destination libvirtd to prevent it from resuming the domain at the
end of migration. This regression was introduced by commit 5379bb0.
---
src/libvirt.c | 22 +++++++++++++---------
src/qemu/qemu_migration.c | 9 ++++++---
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index bc1694a..8e19c64 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4563,16 +4563,17 @@ virDomainMigrateVersion1(virDomainPtr domain,
char *cookie = NULL;
int cookielen = 0, ret;
virDomainInfo info;
- unsigned int destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+ unsigned int destflags;
VIR_DOMAIN_DEBUG(domain,
"dconn=%p, flags=%lx, dname=%s, uri=%s, bandwidth=%lu",
dconn, flags, NULLSTR(dname), NULLSTR(uri), bandwidth);
ret = virDomainGetInfo(domain, &info);
- if (ret == 0 && info.state == VIR_DOMAIN_PAUSED) {
+ if (ret == 0 && info.state == VIR_DOMAIN_PAUSED)
flags |= VIR_MIGRATE_PAUSED;
- }
+
+ destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
/* Prepare the migration.
*
@@ -4659,7 +4660,7 @@ virDomainMigrateVersion2(virDomainPtr domain,
virErrorPtr orig_err = NULL;
unsigned int getxml_flags = 0;
int cancelled;
- unsigned int destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+ unsigned long destflags;
VIR_DOMAIN_DEBUG(domain,
"dconn=%p, flags=%lx, dname=%s, uri=%s, bandwidth=%lu",
@@ -4699,11 +4700,12 @@ virDomainMigrateVersion2(virDomainPtr domain,
return NULL;
ret = virDomainGetInfo(domain, &info);
- if (ret == 0 && info.state == VIR_DOMAIN_PAUSED) {
+ if (ret == 0 && info.state == VIR_DOMAIN_PAUSED)
flags |= VIR_MIGRATE_PAUSED;
- }
- VIR_DEBUG("Prepare2 %p flags=%lx", dconn, flags);
+ destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+
+ VIR_DEBUG("Prepare2 %p flags=%lx", dconn, destflags);
ret = dconn->driver->domainMigratePrepare2
(dconn, &cookie, &cookielen, uri, &uri_out, destflags, dname,
bandwidth, dom_xml);
@@ -4811,7 +4813,7 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
int cancelled = 1;
unsigned long protection = 0;
bool notify_source = true;
- unsigned int destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+ unsigned int destflags;
int state;
virTypedParameterPtr tmp;
@@ -4870,7 +4872,9 @@ virDomainMigrateVersion3Full(virDomainPtr domain,
if (ret == 0 && state == VIR_DOMAIN_PAUSED)
flags |= VIR_MIGRATE_PAUSED;
- VIR_DEBUG("Prepare3 %p flags=%x", dconn, flags);
+ destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+
+ VIR_DEBUG("Prepare3 %p flags=%x", dconn, destflags);
cookiein = cookieout;
cookieinlen = cookieoutlen;
cookieout = NULL;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 49e9e65..6b488ca 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3503,7 +3503,7 @@ static int doPeer2PeerMigrate2(virQEMUDriverPtr driver,
virErrorPtr orig_err = NULL;
bool cancelled;
virStreamPtr st = NULL;
- unsigned int destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+ unsigned long destflags;
VIR_DEBUG("driver=%p, sconn=%p, dconn=%p, vm=%p, dconnuri=%s, "
"flags=%lx, dname=%s, resource=%lu",
@@ -3522,6 +3522,8 @@ static int doPeer2PeerMigrate2(virQEMUDriverPtr driver,
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED)
flags |= VIR_MIGRATE_PAUSED;
+ destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+
VIR_DEBUG("Prepare2 %p", dconn);
if (flags & VIR_MIGRATE_TUNNELLED) {
/*
@@ -3651,8 +3653,7 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
virErrorPtr orig_err = NULL;
bool cancelled = true;
virStreamPtr st = NULL;
- unsigned int destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
-
+ unsigned long destflags;
virTypedParameterPtr params = NULL;
int nparams = 0;
int maxparams = 0;
@@ -3705,6 +3706,8 @@ doPeer2PeerMigrate3(virQEMUDriverPtr driver,
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED)
flags |= VIR_MIGRATE_PAUSED;
+ destflags = flags & ~VIR_MIGRATE_ABORT_ON_ERROR;
+
VIR_DEBUG("Prepare3 %p", dconn);
cookiein = cookieout;
cookieinlen = cookieoutlen;
--
1.8.2.1
11 years, 4 months
[libvirt] [PATCH] add checking index for pci-bridge controller
by Jincheng Miao
hi all,
There is a bug here https://bugzilla.redhat.com/show_bug.cgi?id=981261 about controller configuration.
For the pci-bridge controller, if index less than zero, there is no alert for it, and libvirt will pass this
value to qemu-kvm. But qemu-kvm will report the argument error, like:
"qemu-kvm: -device pci-bridge,chassis_nr=-1,id=pci.-1,bus=pci.0,addr=0x9: Parameter 'chassis_nr' expects uint8_t"
So libvirt should check the arguments of controller.
Here is my patch for pci-bridge:
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -5693,6 +5693,14 @@ virDomainControllerDefParseXML(xmlNodePtr node,
"have an address"));
goto error;
}
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
+ if (def->idx < 0) {
+ virReportError(VIR_ERR_XML_ERROR, "%s",
+ _("pci-bridge controller index invalid, should not "
+ "less than zero"));
+ goto error;
+ }
+
}
And I also see qemuBuildControllerDevStr() in qemu_command.c
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
if (def->idx == 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("PCI bridge index should be > 0"));
goto error;
}
virBufferAsprintf(&buf, "pci-bridge,chassis_nr=%d,id=pci.%d",
def->idx, def->idx);
And if I modify it to "def->idx > 0", testsuite will fail.
So why only check "def->idx == 0" ?
Thanks and regards
Jincheng Miao
11 years, 4 months