]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

14 years agovirsh: better support double quote
Lai Jiangshan [Tue, 12 Oct 2010 07:13:16 +0000 (15:13 +0800)]
virsh: better support double quote

In origin code, double quote is only allowed at the begin or end
"complicated argument"
--some_opt="complicated string"  (we split this argument into 2 parts,
option and data, the data is "complicated string").

This patch makes it allow double quote at any position of
an argument:
complicated" argument"
complicated" "argument
--"some opt=complicated string"

This patch is also needed for the following patches,
the following patches will not split option argument into 2 parts,
so we have to allow double quote at any position of an argument.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
14 years agoDon't fail on missing D-Bus
Guido Günther [Wed, 13 Oct 2010 07:07:48 +0000 (09:07 +0200)]
Don't fail on missing D-Bus

We don't fail when we can't contact HAL so we shouldn't fail if we can't
contact D-Bus either.

14 years agoFixes for documentation extraction
Daniel Veillard [Wed, 13 Oct 2010 10:19:02 +0000 (12:19 +0200)]
Fixes for documentation extraction

* include/libvirt/libvirt.h.in: some of the function type description
  were broken so they could not be automatically documented
* src/util/event.c docs/apibuild.py: event.c exports one public API
  so it needs to be scanned too, avoid a few warnings

14 years agoImplement support for virtio plan9fs filesystem passthrough in QEMU
Daniel P. Berrange [Wed, 2 Jun 2010 14:05:09 +0000 (15:05 +0100)]
Implement support for virtio plan9fs filesystem passthrough in QEMU

Make use of the existing <filesystem> element to support plan9fs
filesystem passthrough in the QEMU driver

    <filesystem type='mount'>
      <source dir='/export/to/guest'/>
      <target dir='/import/from/host'/>
    </filesystem>

NB, the target is not actually a directory, it is merely a arbitrary
string tag that is exported to the guest as a hint for where to mount
it.

14 years agoAdd todo.pl and config example to EXTRA_DIST
Daniel P. Berrange [Wed, 13 Oct 2010 09:58:11 +0000 (10:58 +0100)]
Add todo.pl and config example to EXTRA_DIST

* docs/Makefile.am: Add todo.pl and todo.cfg-example to EXTRA_DIST

14 years agoFix several minor problems introduced by the memtune series
Matthias Bolte [Tue, 12 Oct 2010 19:24:11 +0000 (21:24 +0200)]
Fix several minor problems introduced by the memtune series

Add proper documentation to the new VIR_DOMAIN_MEMORY_* macros in
libvirt.h.in to placate apibuild.py.

Mark args as unused in for libvirt_virDomain{Get,Set}MemoryParameters
in the Python bindings and add both to the libvirtMethods array.

Update remote_protocol-structs to placate make syntax-check.

Undo unintended modifications in vboxDomainGetInfo.

Update the function table of the VirtualBox and XenAPI drivers.

14 years agoRemote protocol implementation of virDomainSet/GetMemoryParameters
Nikunj A. Dadhania [Tue, 12 Oct 2010 17:23:04 +0000 (19:23 +0200)]
Remote protocol implementation of virDomainSet/GetMemoryParameters

14 years agoAdding memtune command to virsh tool
Nikunj A. Dadhania [Tue, 12 Oct 2010 16:56:49 +0000 (18:56 +0200)]
Adding memtune command to virsh tool

The command helps to control the memory/swap parameters for the system, for
eg. hard_limit (max memory the vm can use), soft_limit (limit during memory
contention), swap_hard_limit(max swap the vm can use)

14 years agoAvoid checking against strncpy in virsh.c
Daniel Veillard [Tue, 12 Oct 2010 16:55:47 +0000 (18:55 +0200)]
Avoid checking against strncpy in virsh.c

since the replacement function virStrcpy is not available

14 years agoImplement domainGetMemoryParamters for LXC
Nikunj A. Dadhania [Tue, 12 Oct 2010 16:39:05 +0000 (18:39 +0200)]
Implement domainGetMemoryParamters for LXC

Driver interface for getting memory parameters, eg. hard_limit,
soft_limit and swap_hard_limit.

14 years agoImplement domainSetMemoryParamters for LXC
Nikunj A. Dadhania [Tue, 12 Oct 2010 16:31:19 +0000 (18:31 +0200)]
Implement domainSetMemoryParamters for LXC

Add support in the lxc driver for various memory controllable parameters

14 years agoAdding memtunables to libvirt-lxc command
Nikunj A. Dadhania [Tue, 12 Oct 2010 16:14:44 +0000 (18:14 +0200)]
Adding memtunables to libvirt-lxc command

libvirt-lxc now configures the hardlimit, softlimit and swaplimit, if
specified in the domain xml file or picks up the defaults.

14 years agoAdding memtunables to qemuSetupCgroup
Nikunj A. Dadhania [Tue, 12 Oct 2010 16:12:31 +0000 (18:12 +0200)]
Adding memtunables to qemuSetupCgroup

QEmu startup will pick up the memory tunables specified in the domain
configuration file

14 years agoImplement domainGetMemoryParamters for QEmu
Nikunj A. Dadhania [Tue, 12 Oct 2010 15:50:36 +0000 (17:50 +0200)]
Implement domainGetMemoryParamters for QEmu

Driver interface for getting memory parameters, eg. hard_limit,
soft_limit and swap_hard_limit based on cgroup support

14 years agoImplement domainSetMemoryParamters for QEmu
Nikunj A. Dadhania [Tue, 12 Oct 2010 15:24:54 +0000 (17:24 +0200)]
Implement domainSetMemoryParamters for QEmu

Driver interface for setting memory hard_limit, soft_limit and swap
hard_limit based on cgroup support

14 years agoImplement cgroup memory controller tunables
Nikunj A. Dadhania [Tue, 12 Oct 2010 14:50:53 +0000 (16:50 +0200)]
Implement cgroup memory controller tunables

Provides interfaces for setting/getting memory tunables like hard_limit,
soft_limit and swap_hard_limit

14 years agoXML parsing for memory tunables
Nikunj A. Dadhania [Tue, 12 Oct 2010 14:43:39 +0000 (16:43 +0200)]
XML parsing for memory tunables

Adding parsing code for memory tunables in the domain xml file
also change the internal define structures used for domain memory
informations
Adds a new specific test

14 years agoCleanup some tabs issues
Daniel Veillard [Tue, 12 Oct 2010 14:12:08 +0000 (16:12 +0200)]
Cleanup some tabs issues

14 years agoAdds xml entries for memory tunables in domain schema
Nikunj A. Dadhania [Tue, 12 Oct 2010 14:06:55 +0000 (16:06 +0200)]
Adds xml entries for memory tunables in domain schema

The patch adds xml entries to the domain.rng file.

v2:
+ Fix typo min_guarantee

14 years agoAdding virDomainSetMemoryParameters and virDomainGetMemoryParameters API
Nikunj A. Dadhania [Tue, 12 Oct 2010 14:03:24 +0000 (16:03 +0200)]
Adding virDomainSetMemoryParameters and virDomainGetMemoryParameters API

Public api to set/get memory tunables supported by the hypervisors.

dv:
* some cleanups in libvirt.c
* adding extra checks in libvirt.c new entry points

v4:
* Move exporting public API to this patch
* Add unsigned int flags to the public api for future extensions

v3:
* Add domainGetMemoryParamters and NULL in all the driver interface

v2:
* Initialize domainSetMemoryParameters to NULL in all the driver
  interface structure.

14 years agoAdding structure and defines for virDomainSet/GetMemoryParameters
Nikunj A. Dadhania [Tue, 12 Oct 2010 13:43:27 +0000 (15:43 +0200)]
Adding structure and defines for virDomainSet/GetMemoryParameters

This patch adds a structure virMemoryParameter, it contains the name of
the
parameter and the type of the parameter along with a union.

dv:
+ rename enums to VIR_DOMAIN_MEMORY_PARAM_*
+ remove some extraneous tabs

v4:
+ Add unsigned int flags to the public api for future extensions

v3:
+ Protoype for virDomainGetMemoryParameters and dummy python binding.

v2:
+ Includes dummy python bindings for the library to build cleanly.
+ Define string constants like "hard_limit", etc.
+ re-order this patch.

14 years agocpu: Remove redundant features
Jiri Denemark [Mon, 11 Oct 2010 08:57:04 +0000 (10:57 +0200)]
cpu: Remove redundant features

Some features provided by the recently added CPU models were mentioned
twice for each model. This was a result of automatic generation of the
XML from qemu's CPU configuration file without noticing this redundancy.

14 years agoutil: add missing export
Eric Blake [Tue, 12 Oct 2010 11:35:25 +0000 (05:35 -0600)]
util: add missing export

Commit 1fe2927a3 forgot to export a symbol.

* src/libvirt_private.syms (virHexToBin): Add.
* src/.gitignore: Ignore temporary file.

14 years agoSet sensible defaults for cpu match and feature policy
Daniel P. Berrange [Wed, 22 Sep 2010 11:47:48 +0000 (12:47 +0100)]
Set sensible defaults for cpu match and feature policy

To enable the CPU XML from the capabilities to be pasted directly
into the guest XML with no editing, pick a sensible default for
match and feature policy. The CPU match will be exact and the
feature policy will be require. This should ensure safety for
migration and give DWIM semantics for users

* src/conf/cpu_conf.c: Default to exact match and require policy
* docs/formatdomain.html.in: Document new defaults

14 years agoAdd automatic generation of a todo item page
Daniel P. Berrange [Tue, 21 Sep 2010 15:40:32 +0000 (16:40 +0100)]
Add automatic generation of a todo item page

This adds a script to generate the todo item page from
bugzilla. This requires a valid username+password for
bugzilla, so it is intended that this only be run on
the libvirt.org website via cron. Normal usage will just
generate an empty stub page.

* docs/todo.pl: Script to extract todo items from bugzilla
* docs/todo.cfg-example: Example config file
* docs/sitemap.html.in: Add todo page
* docs/Makefile.am: Generation rules for todo items

14 years agoxen: Fix virDomain{At,De}tachDevice
Jiri Denemark [Fri, 1 Oct 2010 14:45:55 +0000 (16:45 +0200)]
xen: Fix virDomain{At,De}tachDevice

According to API documentation virDomain{At,De}tachDevice calls are
supposed to only work on active guests for device hotplug. For anything
beyond that, their *Flags variants have to be used.

Despite the variant which was acked on libvirt mailing list
(https://www.redhat.com/archives/libvir-list/2010-January/msg00385.html)
commit ed9c14a7ef86d7a45a6d57cbfee5410fca428633 (by Jim Fehlig)
introduced automagic behavior of these API calls for xen driver. Since
January, these calls always change persistent configuration of a guest
and if the guest is currently active, they also hot(un)plug the device.

That change didn't follow API documentation and also broke device
hot(un)plug for older xend implementations which do not support changing
persistent configuration of a guest and hot(un)plugging in one step.

This patch should not break anything for active guests. On the other
hand, changing inactive guests is not supported any more.

14 years agoxen: xenXMDomain*DeviceFlags should obey all flags
Jiri Denemark [Fri, 1 Oct 2010 14:37:53 +0000 (16:37 +0200)]
xen: xenXMDomain*DeviceFlags should obey all flags

xenXMDomain*DeviceFlags() silently ignores requests to modify live
configuration of an active guest while still touching its persistent
configuration.

14 years agoxen: Fix logic bug in xenDaemon*DeviceFlags
Jiri Denemark [Fri, 1 Oct 2010 14:31:04 +0000 (16:31 +0200)]
xen: Fix logic bug in xenDaemon*DeviceFlags

14 years agoxen: Make xenDaemon*DeviceFlags errors less confusing
Jiri Denemark [Fri, 1 Oct 2010 14:22:29 +0000 (16:22 +0200)]
xen: Make xenDaemon*DeviceFlags errors less confusing

When a user calls to virDomain{Attach,Detach,Update}DeviceFlags() with
flags == VIR_DOMAIN_DEVICE_MODIFY_LIVE on an inactive guest running on
an old Xen hypervisor (such as RHEL-5) xend_internal driver reports:

    Xend version does not support modifying persistent config

which is pretty confusing since no-one requested to modify persistent
config.

14 years agoReturn a suitable error message if we can't find a matching emulator
Guido Günther [Fri, 8 Oct 2010 12:16:46 +0000 (14:16 +0200)]
Return a suitable error message if we can't find a matching emulator

14 years agoPass -n to ip(6)tables
Guido Günther [Fri, 8 Oct 2010 14:35:03 +0000 (16:35 +0200)]
Pass -n to ip(6)tables

to avoid long timeouts waiting for DNS servers

14 years agonwfilter: Add 2nd example to the html docs
Stefan Berger [Thu, 7 Oct 2010 10:50:26 +0000 (06:50 -0400)]
nwfilter: Add 2nd example to the html docs

This patch adds another example to the nwfilter html page and provides 2 solutions for how to write a filter meeting the given requirements using newly added features.

14 years agonwfilter: Extend docs with info about the state attribute
Stefan Berger [Thu, 7 Oct 2010 10:45:46 +0000 (06:45 -0400)]
nwfilter: Extend docs with info about the state attribute

I am adding a row with information about the newly supported state
attribute to each of the tables describing supported attributes of protocols.

14 years agonwfilter: Extend schema to accept state attribute
Stefan Berger [Thu, 7 Oct 2010 10:44:41 +0000 (06:44 -0400)]
nwfilter: Extend schema to accept state attribute

Extend the nwfilter.rng schema to accept state attribute.

14 years agonwfilter: Add test case for testing the state attribute
Stefan Berger [Thu, 7 Oct 2010 10:43:35 +0000 (06:43 -0400)]
nwfilter: Add test case for testing the state attribute

This patch adds a test case for testing the XML parser's and instantiator's
support of the state attribute. The other test case tests existing
capabilities. Both test cases will be used in TCK again.

14 years agonwfilter: Instantiate state match in ip(6)tables rules
Stefan Berger [Thu, 7 Oct 2010 10:41:37 +0000 (06:41 -0400)]
nwfilter: Instantiate state match in ip(6)tables rules

In this patch I am extending the rule instantiator to create the state
match according to the state attribute in the XML. Only one iptables
rule in the incoming or outgoing direction will be created for a rule
in direction 'in' or 'out' respectively. A rule in direction 'inout' does
get iptables rules in both directions.

14 years agonwfilter: Extend XML parser and gen. to support state attr.
Stefan Berger [Thu, 7 Oct 2010 10:37:31 +0000 (06:37 -0400)]
nwfilter: Extend XML parser and gen. to support state attr.

The patch below extends the XML parser and generator so that every l3 protocol
now can have a state attribute.

14 years agobuild: require pkg-config for bootstrap
Eric Blake [Tue, 5 Oct 2010 15:10:31 +0000 (09:10 -0600)]
build: require pkg-config for bootstrap

* .gnulib: Update to latest, for bootstrap fixes.
* bootstrap: Synchronize with upstream.
* bootstrap.conf: Add pkg-config pre-requisite.
* autogen.sh: Tweak wording message.
Reported by Justin Clift, and with feedback from Bruno Haible.

14 years agoxen: Fix bogus error when attaching a device
Jiri Denemark [Tue, 5 Oct 2010 11:39:37 +0000 (13:39 +0200)]
xen: Fix bogus error when attaching a device

The xm internal xen driver only supports disk and network devices to be
added to a guest. On an attempt to attach any other device the xm driver
used VIR_ERR_XML_ERROR which resulted in a completely bogus error
message:

error: Failed to attach device from pci.xml
error: XML description for unknown device is not well formed or invalid

14 years agoconfigure: disable network and storage-fs drivers on mac os x
Justin Clift [Tue, 5 Oct 2010 01:31:05 +0000 (12:31 +1100)]
configure: disable network and storage-fs drivers on mac os x

Disabling these two drivers on MacOS X, where they are known to
not work, allows libvirt (including the daemon) to compile without
any further changes.

14 years agonwfilter: fix memory leaks
Stefan Berger [Mon, 4 Oct 2010 10:34:05 +0000 (06:34 -0400)]
nwfilter: fix memory leaks

Fixing memory leak shown by valgrind and freeing buffer in two more places.

14 years agoesx: Add support for virtual serial device network backing
Matthias Bolte [Wed, 29 Sep 2010 21:04:19 +0000 (23:04 +0200)]
esx: Add support for virtual serial device network backing

Since version 4.1 ESX(i) can expose virtual serial devices over TCP.

Add support in the VMX handling code for this, add test cases to cover
it and add links to some documentation.

ESX supports two additional protocols: TELNETS and TLS. Add them to
the list of serial-over-TCP protocols.