]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
14 years agoAdd test suite for virSocket APIs
Daniel P. Berrange [Thu, 21 Oct 2010 18:11:50 +0000 (19:11 +0100)]
Add test suite for virSocket APIs

Add a test suite for check parsing, formatting, range calculation
and netmask checking APIs in virSocketAddr.

* tests/sockettest.c, tests/Makefile.am: Add new test case

14 years agoBan use of all inet_* functions
Daniel P. Berrange [Thu, 21 Oct 2010 10:15:16 +0000 (11:15 +0100)]
Ban use of all inet_* functions

All the inet_* functions can be replaced with calls to the
virSocket APIs. Since many of the inet_* funtions are unsafe,
and the remainder are obsolete, forbid all future use of them
in libvirt.

* Makefile.nonreentrant: Ban use of inet_*

14 years agoRemove all use of inet_pton and inet_ntop
Daniel P. Berrange [Thu, 21 Oct 2010 10:13:05 +0000 (11:13 +0100)]
Remove all use of inet_pton and inet_ntop

The  inet_pton and inet_ntop functions are obsolete, replaced
by getaddrinfo+getnameinfo with the AI_NUMERICHOST flag set.
These can be accessed via the virSocket APIs.

The bridge.c code had methods for fetching the IP address of
a bridge which used inet_ntop. Aside from the use of inet_ntop
these methods are broken, because a NIC can have multiple
addresses and this only returns one address. Since the methods
are never used, just remove them.

* src/conf/network_conf.c, src/nwfilter/nwfilter_learnipaddr.c:
  Replace inet_pton and inet_ntop with virSocket APIs
* src/util/bridge.c, src/util/bridge.h: Remove unused methods
  which called inet_ntop.

14 years agoRemove both addrToString methods
Daniel P. Berrange [Wed, 20 Oct 2010 16:29:56 +0000 (17:29 +0100)]
Remove both addrToString methods

The addrToString functionality is now available via the
virSocketFormatAddrFull method.

* daemon/remote.c, src/remote/remote_driver.c: Remove
  addrToString methods

14 years agoFix error reporting for virSocketParse
Daniel P. Berrange [Wed, 20 Oct 2010 14:20:37 +0000 (15:20 +0100)]
Fix error reporting for virSocketParse

The virSocketParse method was not doing any error reporting
which meant the true cause of the problem was lost. Remove
all error reporting from callers, and push it into virSocketParse

* src/util/network.c: Add error reporting to virSocketParse
* src/conf/domain_conf.c, src/conf/network_conf.c,
  src/network/bridge_driver.c: Remove error reporting in
  callers of virSocketParse

14 years agoExpand virSocketFormat to be more flexible
Daniel P. Berrange [Wed, 20 Oct 2010 14:13:00 +0000 (15:13 +0100)]
Expand virSocketFormat to be more flexible

The getnameinfo() function is more flexible than inet_ntop()
avoiding the need to if/else the code based on socket family.
Also make it support UNIX socket addrs and allow inclusion
of a port (service) address. Finally do proper error reporting
via normal APIs.

* src/conf/domain_conf.c, src/nwfilter/nwfilter_ebiptables_driver.c,
  src/qemu/qemu_conf.c: Fix error handling with virSocketFormat
* src/util/network.c: Rewrite virSocketFormat to use getnameinfo
  and cope with UNIX socket addrs.

14 years agoRemove pointless nwIPAddress struct & void *casts
Daniel P. Berrange [Wed, 20 Oct 2010 13:47:08 +0000 (14:47 +0100)]
Remove pointless nwIPAddress struct & void *casts

The nwIPAddress was simply a wrapper about virSocketAddr.
Just use the latter directly, removing all the extra field
de-references from code & helper APIs for parsing/formatting.

Also remove all the redundant casts from strong types to
void * and then immediately back to strong types.

* src/conf/nwfilter_conf.h: Remove nwIPAddress
* src/conf/nwfilter_conf.c, src/nwfilter/nwfilter_ebiptables_driver.c:
  Update to use virSocketAddr and remove void * casts.

14 years agoFix netmask checks for IPv6 in virSocketCheckNetmask
Daniel P. Berrange [Wed, 20 Oct 2010 13:28:55 +0000 (14:28 +0100)]
Fix netmask checks for IPv6 in virSocketCheckNetmask

There was a typo in the IPv6 path of virSocketCheckNetmask which
caused it to never execute.

* src/util/network.c: s/AF_INET/AF_INET6/ in virSocketCheckNetmask

14 years agoFix passing of address family to virSocketParseAddr
Daniel P. Berrange [Wed, 20 Oct 2010 13:26:30 +0000 (14:26 +0100)]
Fix passing of address family to virSocketParseAddr

The virSocketParseAddr function was accepting any AF_* constant
and using that to set the ai_flags field in struct addrinfo.
This is invalid, since address families must go in the ai_family
field of the struct.

* src/util/network.c: Fix handling of address family
* src/conf/network_conf.c, src/network/bridge_driver.c: Pass
  AF_UNSPEC instead of relying on it being 0.

14 years agoInclude length with virSocketAddr data
Daniel P. Berrange [Wed, 20 Oct 2010 13:21:15 +0000 (14:21 +0100)]
Include length with virSocketAddr data

Some operations on socket addresses need to know the length of
the sockaddr struct for the particular address family. This
info was being discarded when passing around virSocketAddr
instances. Turn it from a union into a struct containing
union+socklen_t fields, so length is always kept around.

* src/util/network.h: Add socklen_t field to virSocketAddr
* src/util/network.c, src/network/bridge_driver.c,
  src/conf/domain_conf.c: Update to take account of new
  struct definition.

14 years agoRemove useless code in error path of getnameinfo()
Daniel P. Berrange [Wed, 20 Oct 2010 12:53:27 +0000 (13:53 +0100)]
Remove useless code in error path of getnameinfo()

If getnameinfo() with NI_NUMERICHOST set fails, there are no
grounds to expect inet_ntop to succeed, since these calls
are functionally equivalent. Remove useless inet_ntop code
in the getnameinfo() error path.

* daemon/remote.c, src/remote/remote_driver.c: Remove
  calls to inet_ntop

14 years agomaint: sort private sym lists
Eric Blake [Wed, 20 Oct 2010 17:10:45 +0000 (11:10 -0600)]
maint: sort private sym lists

* src/libvirt_private.syms: Sort by header name, then within
header, and drop duplicate virNetworkDefParseNode,
virFileLinkPointsTo and virXPathBoolean.

14 years agoEnable JSON and netdev features in QEMU >= 0.13
Daniel P. Berrange [Wed, 20 Oct 2010 17:37:43 +0000 (18:37 +0100)]
Enable JSON and netdev features in QEMU >= 0.13

The QEMU 0.13 release is finally out and from testing in RHEL-6
we know that its JSON and netdev features are now good enough
for us to use by default.

* src/qemu/qemu_conf.c: Enable JSON + netdev for QEMU >= 0.13

14 years agoaudit: simplify declaration
Eric Blake [Wed, 20 Oct 2010 18:21:52 +0000 (12:21 -0600)]
audit: simplify declaration

* src/util/virtaudit.c (virAuditSend): one less ifdef, since gcc
does not care if an ATTRIBUTE_UNUSED var gets used in some paths.

14 years agoqemu: Exit on first error in qemuDomainGetMemoryParameters
Matthias Bolte [Wed, 20 Oct 2010 12:28:45 +0000 (14:28 +0200)]
qemu: Exit on first error in qemuDomainGetMemoryParameters

There is no point in trying to fill params beyond the first error,
because when qemuDomainGetMemoryParameters returns -1 then the caller
cannot detect which values in params are valid.

14 years agovirsh: Don't read nparams when virDomainGetMemoryParameters fails
Matthias Bolte [Wed, 20 Oct 2010 12:16:28 +0000 (14:16 +0200)]
virsh: Don't read nparams when virDomainGetMemoryParameters fails

Also exit early when nparams is 0.

14 years agoRename VIR_DOMAIN_SWAP_HARD_LIMIT to VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT
Matthias Bolte [Wed, 20 Oct 2010 11:52:48 +0000 (13:52 +0200)]
Rename VIR_DOMAIN_SWAP_HARD_LIMIT to VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT

To get them under the common VIR_DOMAIN_MEMORY_* prefix.

14 years agoFix formatting of the memtune XML element
Matthias Bolte [Wed, 20 Oct 2010 11:22:40 +0000 (13:22 +0200)]
Fix formatting of the memtune XML element

Also output the min_guarantee element when set.

14 years agoFix make check on RHEL-5
Jiri Denemark [Wed, 20 Oct 2010 14:14:18 +0000 (16:14 +0200)]
Fix make check on RHEL-5

The test for <vcpu> element is unrelated to vnc so the easiest fix is to
remove related configuration.

14 years agoDon't let daemon-conf test fail when auditing is disabled
Matthias Bolte [Tue, 19 Oct 2010 18:27:51 +0000 (20:27 +0200)]
Don't let daemon-conf test fail when auditing is disabled

14 years agoUpdate comments for the memory tunables macros
Nikunj A. Dadhania [Wed, 20 Oct 2010 09:38:39 +0000 (11:38 +0200)]
Update comments for the memory tunables macros

* include/libvirt/libvirt.h.in: Update comment with actual description

14 years agoAdd John Morrissey to AUTHORS
Daniel Veillard [Wed, 20 Oct 2010 08:32:57 +0000 (10:32 +0200)]
Add John Morrissey to AUTHORS

14 years agoAdd process= support for 'qemu-kvm -name'
John Morrissey [Wed, 20 Oct 2010 08:25:05 +0000 (10:25 +0200)]
Add process= support for 'qemu-kvm -name'

This sets the process name to the same value as the Windows title,
but since the name is limited to 16 chars only this is kept as a
configuration option and turned off by default
* src/qemu/qemu.conf src/qemu/qemu_conf.[ch]: hceck for support in the
  QEmu help output, add the option in qemu conf file and augment
  qemudBuildCommandLine to add it if switched on
* src/qemu/libvirtd_qemu.aug src/qemu/test_libvirtd_qemu.aug: augment
  the augeas lenses accordingly
* tests/qemuhelptest.c: cope with the extra flag being detected now

14 years agonwfilter: avoid dir. enforcement for certain types of rules
Stefan Berger [Tue, 19 Oct 2010 23:25:37 +0000 (19:25 -0400)]
nwfilter: avoid dir. enforcement for certain types of rules

 Avoid the enforcement of direction if
- icmp rules specify the type/code information
- the 'skipMatch' variable is set to 'true'

14 years agodocs: added initial page for c# binding, with links to it
Justin Clift [Tue, 19 Oct 2010 19:48:40 +0000 (06:48 +1100)]
docs: added initial page for c# binding, with links to it

Adds a new page for the C# language bindings being developed by Arnaud
Champion.

14 years agoDon't fail lxc domain start when memory controller support is missing
Guido Günther [Fri, 15 Oct 2010 08:01:38 +0000 (10:01 +0200)]
Don't fail lxc domain start when memory controller support is missing

Debian stock kernel has CONFIG_CGROUP_MEM_RES_CTLR disabled due to the
overhead [1]. Allow to start containers if the corresponding files in
the cgroup filesystem are missing. This fixes Debian bug #566180 [2].

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=534964
[2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566180

14 years agoFix compile errors in remote.c and newly added audit code
Matthias Bolte [Tue, 19 Oct 2010 17:01:26 +0000 (19:01 +0200)]
Fix compile errors in remote.c and newly added audit code

14 years agoFix symbol exports & remove duplicated libvirt_util.la linkage
Daniel P. Berrange [Tue, 12 Oct 2010 11:23:18 +0000 (12:23 +0100)]
Fix symbol exports & remove duplicated libvirt_util.la linkage

The libvirt_util.la library was mistakenly linked into libvirtd
directly. Since libvirt_util.la is already linked to libvirt.so,
this resulted in libvirtd getting two copies of the code and
more critically 2 copies of static global variables.

Testing in turn exposed a issue with loadable modules. The
gnulib replacement functions are not exported to loadable
modules. Rather than trying to figure out the name sof all
gnulib functions & export them, just linkage all loadable
modules against libgnu.la statically.

* daemon/Makefile.am: Remove linkage of libvirt_util.la
  and libvirt_driver.la
* src/Makefile.am: Link driver modules against libgnu.la
* src/libvirt.c: Don't try to load modules which were
  compiled out
* src/libvirt_private.syms: Export all other internal
  symbols that are required  by drivers

14 years agoAudit SELinux label assignment.
Miloslav Trmač [Tue, 12 Oct 2010 11:23:55 +0000 (12:23 +0100)]
Audit SELinux label assignment.

A more natural auditing point would perhaps be
SELinuxSetSecurityProcessLabel, but this happens in the child after root
permissions are dropped, so the kernel would refuse the audit record.

14 years agoAudit VM start/stop/suspend/resume
Miloslav Trmač [Tue, 12 Oct 2010 11:22:03 +0000 (12:22 +0100)]
Audit VM start/stop/suspend/resume

Most operations are audited at the libvirtd level; auditing in
src/libvirt.c would result in two audit entries per operation (one in
the client, one in libvirtd).

The only exception is a domain stopping of its own will (e.g. because
the user clicks on "shutdown" inside the interface).  There can often be
no client connected at the time the domain stops, so libvirtd does not
have any virConnectPtr object on which to attach an event watch.  This
patch therefore adds auditing directly inside the qemu driver (other
drivers are not supported).

14 years agoBasic framework for auditing integration
Daniel P. Berrange [Wed, 15 Sep 2010 13:44:11 +0000 (14:44 +0100)]
Basic framework for auditing integration

Integrate with libaudit.so for auditing of important operations.
libvirtd gains a couple of config entries for auditing. By
default it will enable auditing, if its enabled on the host.
It can be configured to force exit if auditing is disabled
on the host. It will can also send audit messages via libvirt
internal logging API

Places requiring audit reporting can use the VIR_AUDIT
macro to report data. This is a no-op unless auditing is
enabled

* autobuild.sh, mingw32-libvirt.spec.in: Disable audit
  on mingw
* configure.ac: Add check for libaudit
* daemon/libvirtd.aug, daemon/libvirtd.conf,
  daemon/test_libvirtd.aug, daemon/libvirtd.c: Add config
  options to enable auditing
* include/libvirt/virterror.h, src/util/virterror.c: Add
  VIR_FROM_AUDIT source
* libvirt.spec.in: Enable audit
* src/util/virtaudit.h, src/util/virtaudit.c: Simple internal
  API for auditing messages

14 years agoFix statstest when driver modules are enabled
Daniel P. Berrange [Thu, 14 Oct 2010 12:22:18 +0000 (13:22 +0100)]
Fix statstest when driver modules are enabled

The statstest is xen specific. Instead of filling the code with
a huge number of #ifdef WITH_XEN, just make its entire compilation
conditional in the Makefile.am. Also ensure it links to the Xen
driver so that it builds when driver modules are enabled

* tests/Makefile.am: Make statstest xen conditional. Link to
  xen driver
* tests/Makefile.am: Remove all conditionals

14 years agovirsh: consolidate memtune docs
Eric Blake [Tue, 19 Oct 2010 15:39:51 +0000 (09:39 -0600)]
virsh: consolidate memtune docs

* tools/virsh.pod (memtune): Drop second copy, fill to 80 columns,
enhance wording.

14 years agovcpu: remove dead xen code
Eric Blake [Thu, 7 Oct 2010 14:59:27 +0000 (08:59 -0600)]
vcpu: remove dead xen code

* src/xen/xen_driver.h (xenUnifiedDriver): Remove now-unused
domainGetMaxVcpus, domainSetVcpus.
* src/xen/proxy_internal.c (xenProxyDriver): Likewise.
* src/xen/xen_hypervisor.c (xenHypervisorDriver): Likewise.
* src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
* src/xen/xend_internal.c (xenDaemonDriver)
(xenDaemonDomainSetVcpus): Likewise.
* src/xen/xm_internal.c (xenXMDriver, xenXMDomainSetVcpus):
Likewise.
* src/xen/xs_internal.c (xenStoreDriver): Likewise.

14 years agovcpu: improve support for setting xen vcpu counts
Eric Blake [Thu, 14 Oct 2010 22:17:18 +0000 (16:17 -0600)]
vcpu: improve support for setting xen vcpu counts

Tested with RHEL 5.6 (xendConfigVersion 2, where xend_internal
controls live domains and xm_internal controls inactive domains).
Hopefully this works with xendConfigVersion 3 (where xend_internal
controls everything).

* src/xen/xen_driver.c (xenUnifiedDomainSetVcpusFlags): Support
more flags.
(xenUnifiedGetMaxVcpus): Export.
* src/xen/xm_internal.h (xenXMDomainSetVcpusFlags): New prototype.
* src/xen/xend_internal.h (xenDaemonDomainSetVcpusFlags): Likewise.
* src/xen/xen_driver.h (xenUnifiedGetMaxVcpus): Likewise.
* src/xen/xm_internal.c (xenXMDomainSetVcpusFlags): New function.
* src/xen/xend_internal.c (xenDaemonDomainSetVcpusFlags): Likewise.

14 years agovcpu: improve support for getting xen vcpu counts
Eric Blake [Wed, 6 Oct 2010 23:54:41 +0000 (17:54 -0600)]
vcpu: improve support for getting xen vcpu counts

* src/xen/xen_driver.c (xenUnifiedDomainGetVcpusFlags): Support
more flags.
* src/xen/xend_internal.h (xenDaemonDomainGetVcpusFlags): New
prototype.
* src/xen/xm_internal.h (xenXMDomainGetVcpusFlags): Likewise.
* src/xen/xend_internal.c (virDomainGetVcpusFlags): New function.
* src/xen/xm_internal.c (xenXMDomainGetVcpusFlags): Likewise.

14 years agovcpu: improve vcpu support in xen command line
Eric Blake [Tue, 5 Oct 2010 14:18:52 +0000 (08:18 -0600)]
vcpu: improve vcpu support in xen command line

This patch series focuses on xendConfigVersion 2 (xm_internal) and 3
(xend_internal), but leaves out changes for xenapi drivers.

See this link for more details about vcpu_avail for xm usage.
http://lists.xensource.com/archives/html/xen-devel/2009-11/msg01061.html

This relies on the fact that def->maxvcpus can be at most 32 with xen.

* src/xen/xend_internal.c (xenDaemonParseSxpr)
(sexpr_to_xend_domain_info, xenDaemonFormatSxpr): Use vcpu_avail
when current vcpus is less than maximum.
* src/xen/xm_internal.c (xenXMDomainConfigParse)
(xenXMDomainConfigFormat): Likewise.
* tests/xml2sexprdata/xml2sexpr-pv-vcpus.sexpr: New file.
* tests/sexpr2xmldata/sexpr2xml-pv-vcpus.sexpr: Likewise.
* tests/sexpr2xmldata/sexpr2xml-pv-vcpus.xml: Likewise.
* tests/xmconfigdata/test-paravirt-vcpu.cfg: Likewise.
* tests/xmconfigdata/test-paravirt-vcpu.xml: Likewise.
* tests/xml2sexprtest.c (mymain): New test.
* tests/sexpr2xmltest.c (mymain): Likewise.
* tests/xmconfigtest.c (mymain): Likewise.

14 years agovcpu: complete vcpu support in qemu driver
Eric Blake [Wed, 29 Sep 2010 23:40:45 +0000 (17:40 -0600)]
vcpu: complete vcpu support in qemu driver

* src/qemu/qemu_driver.c (qemudDomainSetVcpusFlags)
(qemudDomainGetVcpusFlags): Support all feasible flag
combinations.

14 years agovcpu: improve vcpu support in qemu command line
Eric Blake [Wed, 29 Sep 2010 21:58:47 +0000 (15:58 -0600)]
vcpu: improve vcpu support in qemu command line

* src/qemu/qemu_conf.c (qemuParseCommandLineSmp): Distinguish
between vcpus and maxvcpus, for new enough qemu.
* tests/qemuargv2xmltest.c (mymain): Add new test.
* tests/qemuxml2argvtest.c (mymain): Likewise.
* tests/qemuxml2xmltest.c (mymain): Likewise.
* tests/qemuxml2argvdata/qemuxml2argv-smp.args: New file.

14 years agovcpu: support all flags in test driver
Eric Blake [Mon, 4 Oct 2010 23:01:12 +0000 (17:01 -0600)]
vcpu: support all flags in test driver

* src/test/test_driver.c (testDomainGetVcpusFlags)
(testDomainSetVcpusFlags): Support all flags.
(testDomainUpdateVCPUs): Update cpu count here.

14 years agovcpu: add virsh support
Eric Blake [Wed, 29 Sep 2010 21:20:23 +0000 (15:20 -0600)]
vcpu: add virsh support

* tools/virsh.c (cmdSetvcpus): Add new flags.  Let invalid
commands through to driver, to ease testing of hypervisor argument
validation.
(cmdMaxvcpus, cmdVcpucount): New commands.
(commands): Add new commands.
* tools/virsh.pod (setvcpus, vcpucount, maxvcpus): Document new
behavior.

14 years agovcpu: support maxvcpu in domain_conf
Eric Blake [Wed, 29 Sep 2010 16:20:07 +0000 (10:20 -0600)]
vcpu: support maxvcpu in domain_conf

Although this patch adds a distinction between maximum vcpus and
current vcpus in the XML, the values should be identical for all
drivers at this point.  Only in subsequent per-driver patches will
a distinction be made.

In general, virDomainGetInfo should prefer the current vcpus.

* src/conf/domain_conf.h (_virDomainDef): Adjust vcpus to unsigned
short, to match virDomainGetInfo limit.  Add maxvcpus member.
* src/conf/domain_conf.c (virDomainDefParseXML)
(virDomainDefFormat): parse and print out vcpu details.
* src/xen/xend_internal.c (xenDaemonParseSxpr)
(xenDaemonFormatSxpr): Manage both vcpu numbers, and require them
to be equal for now.
* src/xen/xm_internal.c (xenXMDomainConfigParse)
(xenXMDomainConfigFormat): Likewise.
* src/phyp/phyp_driver.c (phypDomainDumpXML): Likewise.
* src/openvz/openvz_conf.c (openvzLoadDomains): Likewise.
* src/openvz/openvz_driver.c (openvzDomainDefineXML)
(openvzDomainCreateXML, openvzDomainSetVcpusInternal): Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainDumpXML, vboxDomainDefineXML):
Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainDumpXML): Likewise.
* src/xenapi/xenapi_utils.c (createVMRecordFromXml): Likewise.
* src/esx/esx_vmx.c (esxVMX_ParseConfig, esxVMX_FormatConfig):
Likewise.
* src/qemu/qemu_conf.c (qemuBuildSmpArgStr)
(qemuParseCommandLineSmp, qemuParseCommandLine): Likewise.
* src/qemu/qemu_driver.c (qemudDomainHotplugVcpus): Likewise.
* src/opennebula/one_conf.c (xmlOneTemplate): Likewise.

14 years agovcpu: make old API trivially wrap to new API
Eric Blake [Mon, 27 Sep 2010 22:37:53 +0000 (16:37 -0600)]
vcpu: make old API trivially wrap to new API

Note - this wrapping is completely mechanical; the old API will
function identically, since the new API validates that the exact
same flags are provided by the old API.  On a per-driver basis,
it may make sense to have the old API pass a different set of flags,
but that should be done in the per-driver patch that implements
the full range of flag support in the new API.

* src/esx/esx_driver.c (esxDomainSetVcpus, escDomainGetMaxVpcus):
Move guts...
(esxDomainSetVcpusFlags, esxDomainGetVcpusFlags): ...to new
functions.
(esxDriver): Trivially support the new API.
* src/openvz/openvz_driver.c (openvzDomainSetVcpus)
(openvzDomainSetVcpusFlags, openvzDomainGetMaxVcpus)
(openvzDomainGetVcpusFlags, openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDomainSetCPU)
(phypDomainSetVcpusFlags, phypGetLparCPUMAX)
(phypDomainGetVcpusFlags, phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemudDomainSetVcpus)
(qemudDomainSetVcpusFlags, qemudDomainGetMaxVcpus)
(qemudDomainGetVcpusFlags, qemuDriver): Likewise.
* src/test/test_driver.c (testSetVcpus, testDomainSetVcpusFlags)
(testDomainGetMaxVcpus, testDomainGetVcpusFlags, testDriver):
Likewise.
* src/vbox/vbox_tmpl.c (vboxDomainSetVcpus)
(vboxDomainSetVcpusFlags, virDomainGetMaxVcpus)
(virDomainGetVcpusFlags, virDriver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDomainSetVcpus)
(xenUnifiedDomainSetVcpusFlags, xenUnifiedDomainGetMaxVcpus)
(xenUnifiedDomainGetVcpusFlags, xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainSetVcpus)
(xenapiDomainSetVcpusFlags, xenapiDomainGetMaxVcpus)
(xenapiDomainGetVcpusFlags, xenapiDriver): Likewise.
(xenapiError): New helper macro.

14 years agovcpu: implement the remote protocol
Eric Blake [Mon, 27 Sep 2010 16:10:06 +0000 (10:10 -0600)]
vcpu: implement the remote protocol

Done by editing the first three files, then running
'make -C src rpcgen', then editing src/remote_protocol-structs
to match.

* daemon/remote.c (remoteDispatchDomainSetVcpusFlags)
(remoteDispatchDomainGetVcpusFlags): New functions.
* src/remote/remote_driver.c (remoteDomainSetVcpusFlags)
(remoteDomainGetVcpusFlags, remote_driver): Client side
serialization.
* src/remote/remote_protocol.x
(remote_domain_set_vcpus_flags_args)
(remote_domain_get_vcpus_flags_args)
(remote_domain_get_vcpus_flags_ret)
(REMOTE_PROC_DOMAIN_SET_VCPUS_FLAGS)
(REMOTE_PROC_DOMAIN_GET_VCPUS_FLAGS): Define wire format.
* daemon/remote_dispatch_args.h: Regenerate.
* daemon/remote_dispatch_prototypes.h: Likewise.
* daemon/remote_dispatch_table.h: Likewise.
* src/remote/remote_protocol.c: Likewise.
* src/remote/remote_protocol.h: Likewise.
* src/remote_protocol-structs: Likewise.

14 years agovcpu: implement the public APIs
Eric Blake [Mon, 27 Sep 2010 15:37:22 +0000 (09:37 -0600)]
vcpu: implement the public APIs

Factors common checks (such as nonzero vcpu count) up front, but
drivers will still need to do additional flag checks.

* src/libvirt.c (virDomainSetVcpusFlags, virDomainGetVcpusFlags):
New functions.
(virDomainSetVcpus, virDomainGetMaxVcpus): Refer to new API.

14 years agovcpu: define internal driver API
Eric Blake [Mon, 27 Sep 2010 15:18:22 +0000 (09:18 -0600)]
vcpu: define internal driver API

* src/driver.h (virDrvDomainSetVcpusFlags)
(virDrvDomainGetVcpusFlags): New typedefs.
(_virDriver): New callback members.
* src/esx/esx_driver.c (esxDriver): Add stub for driver.
* src/lxc/lxc_driver.c (lxcDriver): Likewise.
* src/opennebula/one_driver.c (oneDriver): Likewise.
* src/openvz/openvz_driver.c (openvzDriver): Likewise.
* src/phyp/phyp_driver.c (phypDriver): Likewise.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/test/test_driver.c (testDriver): Likewise.
* src/uml/uml_driver.c (umlDriver): Likewise.
* src/vbox/vbox_tmpl.c (Driver): Likewise.
* src/xen/xen_driver.c (xenUnifiedDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDriver): Likewise.

14 years agovcpu: add new public API
Eric Blake [Fri, 24 Sep 2010 22:48:45 +0000 (16:48 -0600)]
vcpu: add new public API

API agreed on in
https://www.redhat.com/archives/libvir-list/2010-September/msg00456.html,
but modified for enum names to be consistent with virDomainDeviceModifyFlags.

* include/libvirt/libvirt.h.in (virDomainVcpuFlags)
(virDomainSetVcpusFlags, virDomainGetVcpusFlags): New
declarations.
* src/libvirt_public.syms: Export new symbols.

14 years agovcpu: add current attribute to <vcpu> element
Eric Blake [Mon, 27 Sep 2010 23:36:06 +0000 (17:36 -0600)]
vcpu: add current attribute to <vcpu> element

Syntax agreed on in
https://www.redhat.com/archives/libvir-list/2010-September/msg00476.html

<domain ...>
  <vcpu current='x'>y</vcpu>
...

can now be used to specify 1 <= x <= y current vcpus, in relation
to the boot-time max of y vcpus.  If current is omitted, then
current and max are assumed to be the same value.

* docs/schemas/domain.rng: Add new attribute.
* docs/formatdomain.html.in: Document it.
* tests/qemuxml2argvdata/qemuxml2argv-smp.xml: Add to
domainschematest.
* tests/xml2sexprdata/xml2sexpr-pv-vcpus.xml: Likewise.

14 years agonwfilter: changes to rules in VM->host table
Stefan Berger [Tue, 19 Oct 2010 15:35:58 +0000 (11:35 -0400)]
nwfilter: changes to rules in VM->host table

In the table built for traffic coming from the VM going to the host make the following changes:

- don't ACCEPT the packets but do a 'RETURN' and let the host-specific firewall rules in subsequent rules evaluate whether the traffic is allowed to enter

- use the '-m state' in the rules as everywhere else

14 years agobuild: avoid false positive syntax-check failure
Eric Blake [Tue, 19 Oct 2010 15:23:50 +0000 (09:23 -0600)]
build: avoid false positive syntax-check failure

* .x-sc_po_check: Exclude docs directory.

14 years agoproxy: Fix undefined reference to virClose
Matthias Bolte [Tue, 19 Oct 2010 14:43:59 +0000 (16:43 +0200)]
proxy: Fix undefined reference to virClose

Add src/util/files.c to libvirt_proxy_SOURCES.

14 years agoesx: Handle non-UTF-8 encoded VMX files
Matthias Bolte [Fri, 15 Oct 2010 15:50:23 +0000 (17:50 +0200)]
esx: Handle non-UTF-8 encoded VMX files

ESX(i) uses UTF-8, but a Windows based GSX server writes
Windows-1252 encoded VMX files.

Add a test case to ensure that libxml2 provides Windows-1252
to UTF-8 conversion.

14 years agoIntroduce VIR_CLOSE to be used rather than close()
Stefan Berger [Tue, 19 Oct 2010 14:23:51 +0000 (10:23 -0400)]
Introduce VIR_CLOSE to be used rather than close()

Since bugs due to double-closed file descriptors are difficult to track down in a multi-threaded system, I am introducing the VIR_CLOSE(fd) macro to help avoid mistakes here.

There are lots of places where close() is being used. In this patch I am only cleaning up usage of close() in src/conf where the problems were.

I also dare to declare close() as being deprecated in libvirt code base (HACKING).

14 years agoroot_squash: virFileOperation may fail with EPERM too
Dan Kenigsberg [Tue, 19 Oct 2010 13:26:32 +0000 (15:26 +0200)]
root_squash: virFileOperation may fail with EPERM too

Over root-squashing nfs, when virFileOperation() is called as uid==0,
it may fail with EACCES, but also with EPERM, due to
virFileOperationNoFork()'s failed attemp to chown a writable file.

qemudDomainSaveFlag() should expect this case, too.

14 years agoRun initgroups() in qemudOpenAsUID()
Dan Kenigsberg [Tue, 19 Oct 2010 13:22:57 +0000 (15:22 +0200)]
Run initgroups() in qemudOpenAsUID()

qemudOpenAsUID is intended to open a file with the credentials of a
specified uid. Current implementation fails if the file is accessible to
one of uid's groups but not owned by uid.

This patch replaces the supplementary group list that the child process
inherited from libvirtd with the default group list of uid.

14 years agomemtune: Add min_guarantee to the virsh memtune command
Nikunj A. Dadhania [Tue, 19 Oct 2010 12:45:35 +0000 (14:45 +0200)]
memtune: Add min_guarantee to the virsh memtune command

* tools/virsh.c: Add new memory tunable "min_guarantee", currently only
  ESX can use this
* tools/virsh.pod: Update the manpage

14 years agoUpdate docs for memory parameters and memtune command
Nikunj A. Dadhania [Tue, 19 Oct 2010 12:27:12 +0000 (14:27 +0200)]
Update docs for memory parameters and memtune command

* docs/formatdomain.html.in: Add memtune element details, added min_guarantee
* src/libvirt.c: Update virDomainGetMemoryParameters api description, make
  it more clear that the user first needs to call the api to get the number
  of parameters supported and then call again to get the values.
* tools/virsh.pod: Add usage of new command memtune in virsh manpage

14 years agoqemu: let qemu group look below /var/lib/libvirt/qemu/
Dan Kenigsberg [Mon, 18 Oct 2010 16:21:15 +0000 (10:21 -0600)]
qemu: let qemu group look below /var/lib/libvirt/qemu/

Vdsm needs to communicate with its guest agent via unix domain socket,
which qemu creates due to the following domain xml device:

    <channel type='unix'>
      <target type='virtio' name='com.redhat.rhevm.vdsm'/>
      <source mode='bind' path='/var/lib/libvirt/qemu/channels/fcp-xp-1.com.redhat.rhevm.vdsm'/>
    </channel>

The location of the socket below /var/lib/libvirt/qemu/channels makes
sense, to humans and selinux policy alike. However, that socket should
be accessible to vdsm, too.

Due to other (storage) reasons, vdsm is to join the "qemu" group. With
this patch, vdsm can look below /var/lib/libvirt/qemu and connect to the
socket.

The socket itself should be chmod'ed to allow qemu group read/write, but
that's for another project.

BZ#643407

14 years agoesx: Fix check in esxDomainGetInfo's perf metric handling
Matthias Bolte [Fri, 15 Oct 2010 18:13:04 +0000 (20:13 +0200)]
esx: Fix check in esxDomainGetInfo's perf metric handling

14 years agobuild: use latest gnulib, for ignore-value fix
Eric Blake [Fri, 15 Oct 2010 22:10:18 +0000 (16:10 -0600)]
build: use latest gnulib, for ignore-value fix

* .gnulib: Update to latest.

14 years agovirsh: add tests for recent cli improvements
Eric Blake [Fri, 15 Oct 2010 16:34:11 +0000 (10:34 -0600)]
virsh: add tests for recent cli improvements

* tests/virshtest.c (mymain): Add tests of command parsing and
echo command.

14 years agovirsh: new echo command
Eric Blake [Fri, 15 Oct 2010 13:39:34 +0000 (07:39 -0600)]
virsh: new echo command

* tools/virsh.c (cmdEcho): New command.
(commands): Add it.
* tools/virsh.pod (echo): Document it.

14 years agovirsh: add support for accepting arbitrary argv
Eric Blake [Fri, 15 Oct 2010 13:38:49 +0000 (07:38 -0600)]
virsh: add support for accepting arbitrary argv

* tools/virsh.c (vshCmdOptType): Add VSH_OT_ARGV.  Delete
unused VSH_OT_NONE.
(vshCmddefGetData): Special case new opt flag.
(vshCmddefHelp): Display help for argv.
(vshCommandOptArgv): New function.

14 years agodocs: document how to disable memballoon
Eric Blake [Fri, 15 Oct 2010 19:34:24 +0000 (13:34 -0600)]
docs: document how to disable memballoon

https://bugzilla.redhat.com/show_bug.cgi?id=623903 documents a qemu
bug that causes libvirt to hang if virt-manager happens to be
querying balloon info when a guest is paused.  Until the qemu bug
is fixed, people need to know how to avoid the issue.

* docs/formatdomain.html.in (Memory balloon device): Mention
model='none'.

14 years agoesx: Explictly declare VMX file content as UTF-8
Matthias Bolte [Wed, 13 Oct 2010 21:58:09 +0000 (23:58 +0200)]
esx: Explictly declare VMX file content as UTF-8

14 years agoFix warning about a non-literal format string in qemu_driver.c
Laine Stump [Fri, 15 Oct 2010 15:34:38 +0000 (11:34 -0400)]
Fix warning about a non-literal format string in qemu_driver.c

14 years agobuild: skip xenapi driver when building for RHEL
Eric Blake [Thu, 14 Oct 2010 17:46:41 +0000 (11:46 -0600)]
build: skip xenapi driver when building for RHEL

https://bugzilla.redhat.com/show_bug.cgi?id=643118

* libvirt.spec.in: Provide xenapi conditionals.

14 years agoesx: Handle name escaping properly
Matthias Bolte [Tue, 12 Oct 2010 17:37:39 +0000 (19:37 +0200)]
esx: Handle name escaping properly

VMware uses a mix of percent-, pipe- and base64-encoding in
different combinations in different places.

Add a testcase for this.

14 years agonwfilter: prevent filters with different name but same UUID
Stefan Berger [Thu, 14 Oct 2010 15:53:08 +0000 (11:53 -0400)]
nwfilter: prevent filters with different name but same UUID

Patch to prevent multiple nwfilters with different name but same UUID.

14 years agomaint: add recent author
Eric Blake [Thu, 14 Oct 2010 15:17:42 +0000 (09:17 -0600)]
maint: add recent author

* AUTHORS: List Harsh Prateek Bora, for 'make syntax-check'.

14 years agobuild: fix accidental submodule reversion
Eric Blake [Thu, 14 Oct 2010 13:56:15 +0000 (07:56 -0600)]
build: fix accidental submodule reversion

* .gnulib: Undo change in previous commit.

14 years agonew attribute accessmode to filesystem element
Harsh Prateek Bora [Thu, 14 Oct 2010 13:08:24 +0000 (15:08 +0200)]
new attribute accessmode to filesystem element

This introduces new attribute to filesystem element
to support customizable access mode for mount type.
Valid accessmode are: passthrough, mapped and squash.

Usage:
        <filesystem type='mount' accessmode='passthrough'>
          <source dir='/export/to/guest'/>
          <target dir='mount_tag'/>
        </filesystem>

passthrough is the default model if not specified, that's
also the current behaviour.

14 years agonwfilter: cut off connections after changing filters
Stefan Berger [Thu, 14 Oct 2010 12:54:03 +0000 (08:54 -0400)]
nwfilter: cut off connections after changing filters

The following filter transition from a filter allowing incoming TCP connections

  <rule action='accept' direction='in' priority='401'>
    <tcp/>
  </rule>
  <rule action='accept' direction='out' priority='500'>
    <tcp/>
  </rule>

to one that does not allow them

  <rule action='drop' direction='in' priority='401'>
    <tcp/>
  </rule>
  <rule action='accept' direction='out' priority='500'>
    <tcp/>
  </rule>

did previously not cut off existing (ssh) connections but only prevented newly initiated ones. The attached patch allows to cut off existing connections as well, thus enforcing what the filter is showing.

I had only tested with a configuration where the physical interface is connected to the bridge where the filters are applied. This patch now also solves a filtering problem where the physical interface is not connected to the bridge, but the bridge is given an IP address and the host routes between bridge and physical interface. Here the filters drop non-allowed traffic on the outgoing side on the host.

14 years agobuild: provide URL in 'configure --help'
Eric Blake [Thu, 14 Oct 2010 01:37:25 +0000 (19:37 -0600)]
build: provide URL in 'configure --help'

* configure.ac (AC_INIT): Provide email and URL.

14 years agobuild: fix mingw build
Eric Blake [Wed, 13 Oct 2010 22:14:58 +0000 (16:14 -0600)]
build: fix mingw build

* .gnulib: Update to latest, for termios fix.
* configure.ac (AC_CHECK_HEADERS): Drop redundent check.
* bootstrap: Synchronize from upstream.
Reported by Daniel P. Berrange.

14 years agoqemu: Prohibit migration of guests with host devices
Jiri Denemark [Wed, 13 Oct 2010 13:51:50 +0000 (15:51 +0200)]
qemu: Prohibit migration of guests with host devices

Explicitly raising a nice error in the case user tries to migrate a
guest with assigned host devices is much better than waiting for a
mysterious error with no clue for the reason.

14 years agotests: Honor LIBVIRT_{DEBUG,LOG_*} variables
Jiri Denemark [Wed, 13 Oct 2010 08:41:47 +0000 (10:41 +0200)]
tests: Honor LIBVIRT_{DEBUG,LOG_*} variables

14 years agotests: Do not override LIBVIRT_DEBUG variable
Jiri Denemark [Wed, 13 Oct 2010 08:45:00 +0000 (10:45 +0200)]
tests: Do not override LIBVIRT_DEBUG variable

14 years agocpu: Use vendor in baseline CPU only if all hosts use it
Jiri Denemark [Wed, 13 Oct 2010 10:26:22 +0000 (12:26 +0200)]
cpu: Use vendor in baseline CPU only if all hosts use it

When only some host CPUs given to cpuBaseline contain <vendor> element,
baseline CPU should not contain it. Otherwise the result would not be
compatible with the host CPUs without vendor. CPU vendors are still
taken into account when computing baseline CPU, it's just removed from
the result.

14 years agocpu: Fix vendor for recent CPU models
Jiri Denemark [Wed, 13 Oct 2010 09:42:19 +0000 (11:42 +0200)]
cpu: Fix vendor for recent CPU models

Recent CPU models were specified using invalid vendor element
<vendor>NAME</vendor>, which was silently ignored due to a bug in the
code which was parsing it.

14 years agotest: silence nwfilter test
Stefan Berger [Thu, 14 Oct 2010 00:11:25 +0000 (20:11 -0400)]
test: silence nwfilter test

 This patch silences the nwfilter test case.

14 years agotests: fix spurious test failure
Eric Blake [Wed, 13 Oct 2010 17:31:07 +0000 (11:31 -0600)]
tests: fix spurious test failure

Failure introduced in commit 3a092f389.

* tests/xml2sexprdata/xml2sexpr-boot-grub.sexpr: Fix typo.

14 years agomemory: fix remote protocol compilation
Eric Blake [Wed, 13 Oct 2010 17:09:40 +0000 (11:09 -0600)]
memory: fix remote protocol compilation

'make -C src rpcgen' is supposed to be idempotent.  But commit
f928f43b7b mistakently manually edited a generated file rather
than fixing the upstream file.

* src/remote/remote_protocol.x (remote_memory_param_value): Use
correct spelling of enum values.
* src/remote/remote_protocol.c: Regenerate.

14 years agoEnable support for nested SVM
Daniel P. Berrange [Wed, 22 Sep 2010 11:47:09 +0000 (12:47 +0100)]
Enable support for nested SVM

This enables support for nested SVM using the regular CPU
model/features block. If the CPU model or features include
'svm', then the '-enable-nesting' flag will be added to the
QEMU command line. Latest out of tree patches for nested
'vmx', no longer require the '-enable-nesting' flag. They
instead just look at the cpu features. Several of the models
already include svm support, but QEMU was just masking out
the svm bit silently. So this will enable SVM on such
models

* src/qemu/qemu_conf.h: flag for -enable-nesting
* src/qemu/qemu_conf.c: Use -enable-nesting if VMX or SVM are in
  the CPUID
* src/cpu/cpu.h, src/cpu/cpu.c: API to check for a named feature
* src/cpu/cpu_x86.c: x86 impl of feature check
* src/libvirt_private.syms: Add cpuHasFeature
* src/qemuhelptest.c: Add nesting flag where required

14 years agoImprove error reporting in test suites
Daniel P. Berrange [Wed, 8 Sep 2010 16:12:42 +0000 (17:12 +0100)]
Improve error reporting in test suites

Before running each test case clear the thread local error
indicator. After running each test case, dispatch any error
that was reported

* tests/testutils.c: Fix error reporting in test suites

14 years agoUpdate todo list file to point at bugzilla/website
Daniel P. Berrange [Mon, 23 Aug 2010 13:00:42 +0000 (14:00 +0100)]
Update todo list file to point at bugzilla/website

The TODO list changes frequently so cannot be well maintained
under GIT. Update the TODO file to point people at bugzilla
and the libvirt website

* TODO: Point at bugzilla/website

14 years agoFix Xen SEXPR generation to properly quote strings containing ()
Daniel P. Berrange [Mon, 23 Aug 2010 13:00:22 +0000 (14:00 +0100)]
Fix Xen SEXPR generation to properly quote strings containing ()

* src/xen/sexpr.c: Ensure () are escaped in sexpr2string
* tests/sexpr2xmldata/sexpr2xml-boot-grub.sexpr,
  tests/sexpr2xmldata/sexpr2xml-boot-grub.xml,
  tests/xml2sexprdata/xml2sexpr-boot-grub.sexpr,
  tests/xml2sexprdata/xml2sexpr-boot-grub.xml: Data files to
  check escaping
* tests/sexpr2xmltest.c, tests/xml2sexprtest.c: Add boot-grub
  escaping test case

14 years agonwfilter: resolve deadlock between VM ops and filter update
Stefan Berger [Wed, 13 Oct 2010 14:33:26 +0000 (10:33 -0400)]
nwfilter: resolve deadlock between VM ops and filter update

 This is from a bug report and conversation on IRC where Soren reported that while a filter update is occurring on one or more VMs (due to a rule having been edited for example), a deadlock can occur when a VM referencing a filter is started.

The problem is caused by the two locking sequences of

qemu driver, qemu domain, filter             # for the VM start operation
filter, qemu_driver, qemu_domain            # for the filter update operation

that obviously don't lock in the same order. The problem is the 2nd lock sequence. Here the qemu_driver lock is being grabbed in qemu_driver:qemudVMFilterRebuild()

The following solution is based on the idea of trying to re-arrange the 2nd sequence of locks as follows:

qemu_driver, filter, qemu_driver, qemu_domain

and making the qemu driver recursively lockable so that a second lock can occur, this would then lead to the following net-locking sequence

qemu_driver, filter, qemu_domain

where the 2nd qemu_driver lock has been ( logically ) eliminated.

The 2nd part of the idea is that the sequence of locks (filter, qemu_domain) and (qemu_domain, filter) becomes interchangeable if all code paths where filter AND qemu_domain are locked have a preceding qemu_domain lock that basically blocks their concurrent execution

So, the following code paths exist towards qemu_driver:qemudVMFilterRebuild where we now want to put a qemu_driver lock in front of the filter lock.

-> nwfilterUndefine()   [ locks the filter ]
    -> virNWFilterTestUnassignDef()
        -> virNWFilterTriggerVMFilterRebuild()
            -> qemudVMFilterRebuild()

-> nwfilterDefine()
    -> virNWFilterPoolAssignDef() [ locks the filter ]
        -> virNWFilterTriggerVMFilterRebuild()
            -> qemudVMFilterRebuild()

-> nwfilterDriverReload()
    -> virNWFilterPoolLoadAllConfigs()
        ->virNWFilterPoolObjLoad()
            -> virNWFilterPoolAssignDef() [ locks the filter ]
                -> virNWFilterTriggerVMFilterRebuild()
                    -> qemudVMFilterRebuild()

-> nwfilterDriverStartup()
    -> virNWFilterPoolLoadAllConfigs()
        ->virNWFilterPoolObjLoad()
            -> virNWFilterPoolAssignDef() [ locks the filter ]
                -> virNWFilterTriggerVMFilterRebuild()
                    -> qemudVMFilterRebuild()

Qemu is not the only driver using the nwfilter driver, but also the UML driver calls into it. Therefore qemuVMFilterRebuild() can be exchanged with umlVMFilterRebuild() along with the driver lock of qemu_driver that can now be a uml_driver. Further, since UML and Qemu domains can be running on the same machine, the triggering of a rebuild of the filter can touch both types of drivers and their domains.

In the patch below I am now extending each nwfilter callback driver with functions for locking and unlocking the (VM) driver (UML, QEMU) and introduce new functions for locking all registered callback drivers and unlocking them. Then I am distributing the lock-all-cbdrivers/unlock-all-cbdrivers call into the above call paths. The last shown callpath starting with nwfilterDriverStart() is problematic since it is initialize before the Qemu and UML drives are and thus a lock in the path would result in a NULL pointer attempted to be locked -- the call to virNWFilterTriggerVMFilterRebuild() is never called, so we never lock either the qemu_driver or the uml_driver in that path. Therefore, only the first 3 paths now receive calls to lock and unlock all callback drivers. Now that the locks are distributed where it matters I can remove the qemu_driver and uml_driver lock from qemudVMFilterRebuild() and umlVMFilterRebuild() and not requiring the recursive locks.

For now I want to put this out as an RFC patch. I have tested it by 'stretching' the critical section after the define/undefine functions each lock the filter so I can (easily) concurrently execute another VM operation (suspend,start). That code is in this patch and if you want you can de-activate it. It seems to work ok and operations are being blocked while the update is being done.
I still also want to verify the other assumption above that locking filter and qemu_domain always has a preceding qemu_driver lock.

14 years agovirsh: update comment about parsing
Eric Blake [Tue, 12 Oct 2010 22:23:18 +0000 (16:23 -0600)]
virsh: update comment about parsing

* tools/virsh.c: Update comments to match patch series.

14 years agovirsh: move code into topological order
Eric Blake [Tue, 12 Oct 2010 22:01:02 +0000 (16:01 -0600)]
virsh: move code into topological order

* tools/virsh.c (vshCommandParse): Float up, to avoid the need for
a forward declaration.

14 years agovirsh: simplify top-level option parsing
Eric Blake [Tue, 12 Oct 2010 21:49:13 +0000 (15:49 -0600)]
virsh: simplify top-level option parsing

This makes 'virsh --conn test:///default help help' work right;
previously, the abbreviation confused our hand-rolled option parsing.

* tools/virsh.c (vshParseArgv): Use getopt_long feature, rather
than (incorrectly) reparsing options ourselves.

14 years agovirsh: add -- support
Lai Jiangshan [Tue, 12 Oct 2010 07:14:22 +0000 (15:14 +0800)]
virsh: add -- support

"--" means no option at the following arguments.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: support single quote
Lai Jiangshan [Tue, 12 Oct 2010 07:14:17 +0000 (15:14 +0800)]
virsh: support single quote

Some users may type command like this at the virsh shell:
virsh # somecmd 'some arg'

because they often use single quote in linux shell.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: add escaper \ for command string parsing
Lai Jiangshan [Tue, 12 Oct 2010 07:14:10 +0000 (15:14 +0800)]
virsh: add escaper \ for command string parsing

add escaper \ for command string parsing, example:

virsh # cd /path/which/have/a/double\"quote

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: document options in man page
Eric Blake [Tue, 12 Oct 2010 20:49:28 +0000 (14:49 -0600)]
virsh: document options in man page

* tools/virsh.pod: Document top-level options.

14 years agovirsh: rework command parsing
Lai Jiangshan [Tue, 12 Oct 2010 07:14:01 +0000 (15:14 +0800)]
virsh: rework command parsing

Old virsh command parsing mashes all the args back into a string and
miss the quotes, this patches fix it. It is also needed for introducing
qemu-monitor-command which is very useful.

This patches uses the new vshCommandParser abstraction and adds
vshCommandArgvParse() for arguments vector, so we don't need
to mash arguments vector into a command sting.

And the usage was changed:
old:
virsh [options] [commands]

new:
virsh [options]... [<command_string>]
virsh [options]... <command> [args...]

So we still support commands like:
"define D.xml; dumpxml D" was parsed as a commands-string.

and support commands like:
we will not mash them into a string, we use new argv parser for it.

But we don't support the command like:
"define D.xml; dumpxml" was parsed as a command-name, but we have no such command-name.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: add vshCommandParser abstraction
Lai Jiangshan [Tue, 12 Oct 2010 07:13:50 +0000 (15:13 +0800)]
virsh: add vshCommandParser abstraction

add vshCommandParser and make vshCommandParse() accept different
parsers.

the current code for parse command string is integrated as
vshCommandStringParse().

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: better handling the boolean option
Lai Jiangshan [Tue, 12 Oct 2010 07:13:39 +0000 (15:13 +0800)]
virsh: better handling the boolean option

in old code the following commands are equivalent:
     virsh # dumpxml --update-cpu=vm1
     virsh # dumpxml --update-cpu vm1
because the old code split the option argument into 2 parts:
--update-cpu=vm1 is split into update-cpu and vm1,
and update-cpu is a boolean option, so the parser takes vm1 as another
argument, very strange.

after this patch applied, the first one will become illegal.

To achieve this, we don't parse/check options when parsing command sting,
but check options when parsing a command argument. And the argument is
not split when parsing command sting.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: allow zero length arguments
Lai Jiangshan [Tue, 12 Oct 2010 07:13:28 +0000 (15:13 +0800)]
virsh: allow zero length arguments

the following command is allowed at shell, we also make it allowed at virsh shell.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agovirsh: poison raw allocation routines
Eric Blake [Tue, 12 Oct 2010 17:24:00 +0000 (11:24 -0600)]
virsh: poison raw allocation routines

* tools/virsh.c (malloc, calloc, realloc, strdup): Enforce that
within this file, we use the safe vsh wrappers instead.
(cmdNodeListDevices, cmdSnapshotCreate, main): Fix violations of
this policy.