Commit Graph

2097 Commits

Author SHA1 Message Date
Jim Meyering
f435a3002b uml_conf.c: don't return an uninitialized pointer
* src/uml_conf.c (umlBuildCommandLineChr): Initialize "ret".
2009-09-03 18:04:23 +02:00
Jim Meyering
5cb74dadaf storage_backend.c: assure clang that inputvol can't be NULL
* src/storage_backend.c: Include "internal.h".
(virStorageBackendCopyToFD): Mark inputvol parameter as "nonnull".
Remove test for non-NULL inputvol.  Both callers ensure it's non-NULL.
2009-09-03 18:04:23 +02:00
Jim Meyering
d9b4538469 libvir.c: avoid NULL dereference in virStoragePoolSetAutostart
* src/libvirt.c (virStoragePoolSetAutostart): Return -1 if the pool
argument is invalid, rather than "goto error" where we could dereference
that possibly-NULL "pool".
(virConnectFindStoragePoolSources): Likewise.
(virConnectNumOfDomains): Likewise.
Daniel P. Berrange spotted that the two latter functions
needed the same treatment.
2009-09-03 18:04:23 +02:00
Jim Meyering
1f5e292520 remote_internal.c: appease clang
* src/remote_internal.c (remoteNetworkOpen): Mark "conn" parameter
as non-NULL.  Remove now-unnecessary "conn == NULL" test.
(remoteDevMonOpen): Likewise.
(remoteSecretOpen): Likewise.
(remoteStorageOpen): Likewise.
(remoteInterfaceOpen): Likewise.
2009-09-03 18:04:23 +02:00
Jim Meyering
45aec0eae4 infra: define ATTRIBUTE_NONNULL to mark non-NULL parameters
* src/internal.h (ATTRIBUTE_NONNULL): Define.
2009-09-03 18:04:23 +02:00
Jim Meyering
625f1745dd lxc: don't unlink(NULL) in main
* src/lxc_controller.c (main): Unlink sockpath only if it's non-NULL.
2009-09-03 18:04:23 +02:00
Jim Meyering
e4ac19a87a lxc: avoid NULL dereference upon getmntent failure
* src/lxc_container.c (lxcContainerUnmountOldFS): Don't pass
a NULL pointer to qsort.
2009-09-03 18:04:23 +02:00
Jim Meyering
cff257f584 storage_conf.c: avoid overflow upon use of "z" or "Z" (zebi) suffix
* src/storage_conf.c (virStorageSize): Don't try to compute 1024^7,
since it's too large for a 64-bit type.
2009-09-03 18:04:23 +02:00
Jim Meyering
2e6bad311d storage_backend_fs: avoid NULL dereference on opendir failure
* src/storage_backend_fs.c (virStorageBackendFileSystemRefresh):
Don't call closedir on a NULL pointer.
2009-09-03 18:04:23 +02:00
Pritesh Kothari
da482fe1dd VBox cleanup and update of networking shutdown
* src/vbox/vbox_tmpl.c: merged vboxNetworkUndefine() and
  vboxNetworkDestroy() and added code to handle multiple hostonly
  interfaces.
2009-09-03 17:08:52 +02:00
Pritesh Kothari
32ad6aefca VBox cleanup and update of networking XML functions
* src/vbox/vbox_tmpl.c: merged vboxNetworkCreateXML() and
  vboxNetworkDefineXML() and added code to handle multiple hostonly
  interfaces.
2009-09-03 17:06:03 +02:00
Daniel P. Berrange
85d15b5143 Add support for setting disk drive serial numbers
* docs/schemas/domain.rng: Add <serial> element to disks
* src/domain_conf.h, src/domain_conf.c: XML parsing and
  formatting for disk serial numbers
* src/qemu_conf.c: Set serial number when launching guests
* tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.args,
  tests/qemuxml2argvdata/qemuxml2argv-disk-drive-shared.xml: Add
  serial number to XML test
2009-09-03 13:53:34 +01:00
Daniel P. Berrange
d823a05aef Support configuration of huge pages in guests
Add option to domain XML for

     <memoryBacking>
        <hugepages/>
     </memoryBacking>

* configure.in: Add check for mntent.h
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug, src/qemu.conf
  Add 'hugetlbfs_mount' config parameter
* src/qemu_conf.c, src/qemu_conf.h: Check for -mem-path flag in QEMU,
  and pass it when hugepages are requested.
  Load hugetlbfs_mount config parameter, search for mount if not given.
* src/qemu_driver.c: Free hugetlbfs_mount/path parameter in driver shutdown.
  Create directory for QEMU hugepage usage, chowning if required.
* docs/formatdomain.html.in: Document memoryBacking/hugepages elements
* docs/schemas/domain.rng: Add memoryBacking/hugepages elements to schema
* src/util.c, src/util.h, src/libvirt_private.syms: Add virFileFindMountPoint
  helper API
* tests/qemuhelptest.c: Add -mem-path constants
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add tests for hugepage
  handling
* tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml,
  tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Data files for
  hugepage tests
2009-09-03 13:51:55 +01:00
Daniel P. Berrange
8eacfd4cc2 Fix misc OOM bugs
* tests/testutils.c: Run test function twice, once to prime it for
  static allocations, once to count the non-static allocations.
* tests/testutilsqemu.c: Initialize variable correctl
* src/capabilities.c: Don't free machines variable upon failure
  since caller must do that
* src/xm_internal.c: Add missing check for OOM in building VIF
  config param
2009-09-03 13:14:46 +01:00
Pritesh Kothari
4ff6091294 VBox support for defining/dumping video devices
* src/vbox/vbox_tmpl.c: add setting of video and acceleration in
  VBox driver, and the ability to save this back for serialization
2009-09-03 10:36:44 +02:00
Pritesh Kothari
6aa576cda7 Generic parsing support for video acceleration
* docs/schemas/domain.rng: augment the video model with an optional
  acceleration element with optional accel2d and accel3d flags
* src/domain_conf.c src/domain_conf.h: exten the virDomainVideoDef
  structure with an optional accel field, virDomainVideoAccelDefParseXML
  and virDomainVideoAccelDefFormat functions to parse and serialize
  the structure.
2009-09-03 10:29:35 +02:00
Chris Lalancette
6dfc042c21 Fix bugs in virDomainMigrate v2 code.
Paolo Bonzini points out that in my refactoring of the code for
virDomainMigrate(), I added a check for the return value from
virDomainMigratePerform().  The problem is that we don't want to
exit if we fail, we actually want to go on and do
virDomainMigrateFinish2() with a non-0 return code to clean things
up.  Remove the check.

While reproducing this issue, I also noticed that we wouldn't
always properly propagate an error message.  In particular, I
found that if you blocked off the migration ports (with iptables)
and then tried the migration, it would actually fail but we would
get no failure output from Qemu.  Therefore, we would think we
succeeded, and leave a huge mess behind us.  Execute the monitor
command "info migrate", and look for a failure string in there
as well.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-02 17:23:06 +02:00
Matthias Bolte
b8ee9810b0 VMware ESX: Don't warn on some query parameter
* src/esx/esx_util.c: esxUtil_ParseQuery() warns if a known query
  parameter should be ignored due to the corresponding char/int pointer
  being NULL, instead of silently ignoring it. Fix the control flow.
2009-09-02 16:32:30 +02:00
Matthias Bolte
b6e747ec5a VMware ESX: Allow ethernet address type 'vpx'
* src/esx/esx_vmx.c: add an extra type of addressType beside 'static'
  and 'generated', 'vpx' indicates that the MAC address was generated
  by a vCenter.
2009-09-02 16:24:06 +02:00
Daniel P. Berrange
2d6adabd53 Don't blindly reorder disk drives
Calling qsort() on the disks array causes disk to be
unneccessarily re-ordered, potentially breaking the
ability to boot if the boot disk gets moved later in
the list. The new algorithm will insert a new disk as
far to the end of the list as possible, while being
ordered correctly wrt other disks on the same bus.

* src/domain_conf.c, src/domain_conf.h: Remove disk sorting
  routines. Add API to insert a disk into existing list at
  the optimal position, without resorting disks
* src/libvirt_private.syms: Export virDomainDiskInsert
* src/xend_internal.c, src/xm_internal.c: Remove calls to
  qsort, use virDomainDiskInsert instead.
* src/qemu_driver.c: Remove calls to qsort, use virDoaminDiskInsert
  instead. Fix reordering bugs when hotunplugging disks and
  networks. Fix memory leak in disk/net unplug
2009-09-02 15:19:34 +01:00
Pritesh Kothari
fea5a0bdc9 Support for getting/setting number of cpus in VBox
* src/vbox/vbox_tmpl.c: adds support for getting/setting number of cpus
2009-09-02 16:08:14 +02:00
Daniel P. Berrange
575b18c0f0 Misc fixes to secrets API code
* proxy/Makefile.am: Build storage_encryption_conf.c since its a
  dependancy of domain_conf.c
* src/storage_encryption_conf.c: Disable XML parsing APis when
  build under proxy
* src/test.c: Add a dummy no-op secrets driver for test suite
2009-09-01 21:37:42 +01:00
Daniel P. Berrange
721d3f06c9 Remove redundant base64 include file
* src/storage_encryption_conf.c: Remove base64.h
2009-09-01 21:17:51 +01:00
Miloslav Trmač
28b8cc31f6 Make handling of monitor prompts more general.
* src/qemu_driver.c: Support arbitrary callbacks for "secondary
  prompts".  Reimplement qemudMonitorCommandExtra using such a
  callback.
2009-09-01 18:37:06 +01:00
Miloslav Trmač
077cd91773 Don't assume buffered output echoes the command.
The if ((nlptr...)) implicitly assumes commptr != NULL (and that "buf"
starts with "cmd").  Make the assumption explicit, it will be broken in
a future patch.

* src/qemu_driver.c: Don't assume buffered monitor output echoes the
  command.
2009-09-01 18:36:59 +01:00
Miloslav Trmač
f340964dc9 Attach encryption information to virDomainDiskDef.
The XML allows <encryption format='unencrypted'/>, this implementation
canonicalizes the internal representation so that "disk->encryption" is
non-NULL iff encryption information is available.

A domain with partial encryption information can be defined,
completeness of the information is not verified.  The domain won't
start until the remaining information is added, of course.

* docs/formatdomain.html, docs/formatdomain.html.in: Document
  new encryption options for disks
* docs/schemas/domain.rng: Pull in storage encryption schema
  rules
* src/domain_conf.h, src/domain_conf.c: Wire up storage encryption
  XML parsing/formatting APIs
2009-09-01 18:36:53 +01:00
Miloslav Trmač
46acb0f2b7 Add support for encrypted (qcow) volume creation.
Supports only virStorageVolCreateXML, not virStorageVolCreateXMLFrom.

Curiously, qemu-img does not need the passphrase for anything to create
an encrypted volume.  This implementation thus does not need to touch
any secrets to work with cooperating clients.  More generic passphrase
handling is added in the next patch.

* src/storage_backend.c: Request encryption when creating qcow/qcow2
  files
* src/storage_backend_disk.c, src/storage_backend_fs.c,
  src/storage_backend_logical.c: Refuse to create volumes with
  encryption params set.
2009-09-01 18:27:51 +01:00
Miloslav Trmač
d288703d57 Recognize encryption format of qcow volumes.
(The implementation is not very generic, but that can be very
easily rectified if/when new encryption formats appear.)

* src/storage_backend_fs.c: Probe for qcow/qcow2 encryption
  algorithm field
2009-09-01 18:27:44 +01:00
Miloslav Trmač
eda3af2488 Attach encryption information to virStorageVolDef.
The XML allows <encryption format='unencrypted'/>, this implementation
canonicalizes the internal representation so that "vol->encryption" is
non-NULL iff the volume is encrypted.

Note that partial encryption information (e.g. specifying an encryption
format, but not the key/passphrase) is valid, libvirt will automatically
choose value for the missing information during volume creation.  The
user can read the volume XML, and use the unmodified <encryption> tag in
future operations (without having to be able to understand) its contents.

* docs/formatstorage.html, docs/formatstorage.html.in: Document
  storage volume encryption options
* src/storage_conf.c, src/storage_conf.h: Hook up storage
  encryption XML handling
* tests/storagevolschemadata/vol-qcow2.xml: Test case for encryption
  schema changes
2009-09-01 18:27:38 +01:00
Miloslav Trmač
05b9b8fda3 Add volume encryption information handling.
Define an <encryption> tag specifying volume encryption format and
format-depenedent parameters (e.g. passphrase, cipher name, key
length, key).

Currently the only defined parameter is a reference to a "secret"
(passphrase/key) managed using the virSecret* API.

Only the qcow/qcow2 encryption format, and a "default" format used to
let libvirt choose the format during volume creation, is currently
supported.

This patch does not add any users; the <encryption> tag is added in
the following patches to both volumes (to support encrypted volume
creation) and domains.

* docs/*.html: Re-generate
* docs/formatstorageencryption.html.in, docs/sitemap.html.in:
  Add page describing storage encryption data format
* docs/schemas/Makefile.am, docs/schemas/storageencryption.rng:
  Add RNG schema for storage encryption format
* po/POTFILES.in: Add src/storage_encryption_conf.c
* src/libvirt_private.syms: Export virStorageEncryption* functions
* src/storage_encryption_conf.h, src/storage_encryption_conf.c: Internal
  helper APIs for dealing with storage encryption format
* libvirt.spec.in, mingw32-libvirt.spec.in: Add storageencryption.rng
  RNG schema
2009-09-01 18:27:28 +01:00
Miloslav Trmač
f68c91faa6 Secret manipulation remote client
* src/remote_internal.c: Implement client binding for new secrets
  APIs
* src/datatypes.h: Add 'void *secretPrivateData' to virConnectPtr
  struct
2009-09-01 17:39:25 +01:00
Miloslav Trmač
b35f0131e6 Secret manipulation public API implementation
* include/libvirt/virterror.h, src/virterror.c: Add VIR_ERR_INVALID_SECRET
  and VIR_FROM_SECRET
* src/libvirt.c: Define stubs for every new public API
2009-09-01 17:39:07 +01:00
Miloslav Trmač
eb42e0ab5c Secret manipulation internal API
* include/libvirt/virterror.h, src/virterror.c: Add VIR_WAR_NO_SECRET
* src/libvirt_private.syms, src/datatypes.h, src/datatypes.c: Type
  virSecret struct definition and helper APIs
* src/driver.h: Sub-driver API definitions for secrets
* src/libvirt.c: Define new sub-driver for secrets
2009-09-01 17:38:59 +01:00
Miloslav Trmač
6acc17af8c Secret manipulation public API
This patch adds a "secret" as a separately managed object, using a
special-purpose API to transfer the secret values between nodes and
libvirt users.

* docs/schemas/secret.rng, docs/schemas/Makefilem.am: Add new
  schema for virSecret objects
* docs/*html: Re-generated
* docs/formatsecret.html.in, docs/sitemap.html.in: Add page
  describing the virSecret XML schema
* include/libvirt/libvirt.h.in: Define the new virSecret public
  API
* src/libvirt_public.syms: Export symbols for new public APIs
* mingw32-libvirt.spec.in, libvirt.spec.in: Add secret.rng to
  files list
2009-09-01 17:38:52 +01:00
Charles Duffy
cc76cf31d7 support lzop save compression for qemu
Per prior discussion -- this was, indeed, trivial.

I'm a little disappointed to be breaking the ordering characteristics of
the enum (as it had been ordered by increasing time requirements and
decreasing output size), but breaking any save files with the old
constants in the headers would of course be worse.

>From 2a9cdcfc88de091a8d34aa3fc3b1208d7681790e Mon Sep 17 00:00:00 2001
From: Charles Duffy <Charles_Duffy@dell.com>
Date: Fri, 28 Aug 2009 11:49:54 -0500
Subject: [PATCH] support lzop save compression for qemu

One of the larger disincentives towards use of compression for migrated-out save
files is performance impact. This patch adds support for lzop; CPU time for
compression is about 5x faster than gzip (the next most performant algorithm)
and decompression is about 3x faster.

Signed-off-by: Charles Duffy <Charles_Duffy@dell.com>
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:11:51 +02:00
Chris Lalancette
1dac1b3726 OpenVZ: accept NULL as type for GetMaxVCPUs.
All of the other drivers that support the getMaxVcpus callback
also accept a NULL value for type.  Make openvz also accept a
NULL value.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:03:02 +02:00
Chris Lalancette
776f527926 Remove use of strncpy in qemudExtractMonitorPath.
qemudExtractMonitorPath() was doing a VIR_ALLOC_N followed by a
strncpy.  However, this isn't necessary; we can do the same thing
using strndup, which is much safer.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:01:36 +02:00
Chris Lalancette
bf878aa97e Fix up virNodeGetCellsFreeMemory
The documentation for virNodeGetCellsFreeMemory claims the values
returned are in kilobytes, but that's actually wrong; the value
returned is actually in bytes.  Fix up the documentation to be
correct.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-31 21:01:00 +02:00
Jim Fehlig
8fd7eee90e Fix sexpr2string() to handle empty list.
S-expression containing empty lists, e.g. (cpus (() () () ())),
was not being handled properly in sexpr2string() serialization.
Emit an empty list when encountering NIL sexpr kind.
2009-08-30 11:56:03 +01:00
Daniel P. Berrange
83af050800 Fix driver entry table for UML numa APIs
* src/uml_driver.c: Fix numa API driver entries to avoid
  infinite loop
2009-08-27 19:13:11 +01:00
Pritesh Kothari
544cd63062 Fix crash in virsh vol-key command
* src/virsh.c: Pass in pool object to avoid crash in key lookup
2009-08-27 18:47:41 +01:00
Daniel P. Berrange
3badeffb05 Refactor policycode auth code to avoid compiler warnings
* src/remote_internal.c: Split remoteAuthPolkit into separate
  impls for v0 and v1 to avoid compile warnings due to unused
  variables/params
* qemud/remote.c: Remove accidental tabs
2009-08-25 17:24:12 +01:00
Daniel P. Berrange
8e06c8b3da Support new PolicyKit 1.0 API
* configure.in: Check for pkcheck which indicates new policykit
* qemud/Makefile.am: Install different versions of policy
* qemud/libvirtd.policy: Rename to libvirtd.policy-0
* qemud/libvirtd.policy-1: new style policy
* qemud/qemud.c, qemud/qemud.h, qemud/remote.c: Support new
  policykit API via external pkcheck helper
* src/remote_internal.c: Don't prompt for polkit auth with new
  policykit API
* libvirt.spec.in: deal with new policy install locations & deps
2009-08-25 11:59:14 +01:00
Darryl L. Pierce
777fc2e9d6 517157 fix selinux problem with images on NFS
* src/security_selinux.c: ignores EOPNOTSUPP when attempting to access an
  NFS share
2009-08-21 16:57:29 +02:00
Mattias Bolte
40d46934d0 Fix phypOpen() escape_specialcharacters
Matthias correctly points out that escape_specialcharaters() takes a
length, and since we are now malloc()'ing string in phypOpen instead of
making it a static array, we can't use sizeof(string) anymore.  Calculate
the proper strlen and then use that both to allocate the string and also
pass it to escape_specialcharacters().

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-20 13:59:07 +02:00
Mattias Bolte
1aa1683377 Power Hypervisor: fix potential segfault
I came across this line in the phypOpen function:

char string[strlen(conn->uri->path)];

Here the path part of the given URI is used without checking it for
NULL, this can cause a segfault as strlen expects a string != NULL.
Beside that uuid_db and connection_data leak in case of an error.

In this line

conn->uri->path = string;

the original path of the URI leaks. The patch adds a VIR_FREE call
before setting the new path.

The attached patch is compile-tested but I don't have a Power
Hypervisor installation at hand to test it for real.

Matthias

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-20 12:53:17 +02:00
Chris Lalancette
2e7c8b0b6f Small fixes for qemu save compression.
Fix up a small memory leak pointed out by DanB; I was forgetting
to release memory allocated to driver->saveImageFormat.
Also add the "save_image_format" and "security" entries to
the augeas lens.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-20 09:27:03 +02:00
Mark McLoughlin
3ec80d0112 Fix bridge/tap system error reporting
* src/qemu_conf.c, src/uml_conf.c: use virReportSystemError() to report
  system errors
2009-08-18 14:15:58 +01:00
Mark McLoughlin
2b1f67d418 Don't expose 'vnet%d' to the user
https://bugzilla.redhat.com/517371

Matt Booth points out that if you use a non-existent bridge name when
start a guest you get a weird error message:

  Failed to add tap interface 'vnet%d' to bridge 'virbr0'

and dev='vnet%d' appears in the dumpxml output.

Fix that by not including 'vnet%d' in the error message and freeing the
'vnet%d' string if adding the tap device to the bridge fails.

* src/qemu_conf.c, src/uml_conf.c: fix qemudNetworkIfaceConnect()
  and umlConnectTapDevice() to not expose 'vnet%d' to the user
2009-08-18 13:36:37 +01:00
Mark McLoughlin
e8ad339312 Maintain a list of active PCI hostdevs and use it in pciResetDevice()
As we start/shutdown guests, or hotplug/hot-unplug devices, we can add
or delete devices as appropriate from a list of active devices.

Then, in pciReset(), we can use this to determine whether its safe to
reset a device as a side effect of resetting another device.

* src/qemu_conf.h: add activePciHostdevs to qemud_driver

* src/qemu_driver.c: maintain the activePciHostdevs list, and pass it
  to pciResetDevice()

* src/pci.[ch]: pass the activeDevs list to pciResetDevice() and use
  it to determine whether a Secondary Bus Reset is safe
2009-08-18 09:41:57 +01:00
Mark McLoughlin
78675b228b Simplify PCI hostdev prepare/re-attach using a pciDeviceList type
The qemuPrepareHostDevices() and qemuDomainReAttachHostDevices()
functions are clutter with a bunch of calls to pciGetDevice() and
pciFreeDevice() obscuring the basic logic.

Add a pciDeviceList type and add a qemuGetPciHostDeviceList() function
to build a list from a domain definition. Use this in prepare/re-attach
fto simplify things and eliminate the multiple pciGetDevice calls.

This is especially useful because in the next patch we need to iterate
the hostdevs list a third time and we also need a list type for keeping
track of active devices.

* src/pci.[ch]: add pciDeviceList type and also a per-device 'managed'
  property

* src/libvirt_private.syms: export the new functions

* src/qemu_driver.c: add qemuGetPciHostDeviceList() and re-write
  qemuPrepareHostDevices() and qemuDomainReAttachHostDevices() to use it
2009-08-18 09:41:57 +01:00
Mark McLoughlin
60ff07585c Use pci_addr=auto with QEMU's pci_add monitor command
Newer versions of QEMU accept 'pci_add auto', but older versions require
'pci_add pci_addr=auto'

* src/qemu_driver.c: use pci_addr= in qemudDomainAttachHostPciDevice()
  for older versions of QEMU
2009-08-18 09:41:57 +01:00
Mark McLoughlin
457e050628 Fix thinko in PCI hostdev detach
* src/qemu_driver.c: Add missing break statement in
  qemudDomainDetachHostDevice()
2009-08-18 09:41:57 +01:00
Mark McLoughlin
12edef9a6a Reset PCI host devices after hot-unplug
When we hot-unplug a PCI host device from a guest, we should reset it.

Both managed and unmanaged devices should be reset, but only managed
devices should be re-attached.

* src/qemu_driver.c: reset devices in qemudDomainDetachHostPciDevice()
2009-08-18 09:41:57 +01:00
Mark McLoughlin
4dbecff9fb Reset unmanaged PCI host devices before hotplug
Right now we're only resetting managed devices before hotplug, but we
should reset them irrespective of whether they are managed.

* src/qemu_driver.c: reset all PCI hostdevs before hotplug
2009-08-18 09:41:57 +01:00
Mark McLoughlin
4954e079c8 Revert changes to allow pciResetDevice() reset multiple devices
It turns out that the previous attempt at this doesn't work well
in the case of hotplug. We need qemuCheckPciHostDevice() to
disallow the reset affecting devices already attach to the guest,
but we still need to avoid double locking the virDomainObjPtr.

This is all getting messy, I've a better idea.

This reverts commit 6318808270 and
c106c8a18c.

* src/qemu_driver.c, src/pci.[ch], src/xen_unified.c,
  src/libvirt_private.syms: revert a bunch of stuff.
2009-08-18 09:41:56 +01:00
Mark McLoughlin
0b973381dc Fix list updating after disk/network/hostdev hot-unplug
The current code makes a poor effort at updating the device arrays after
hot-unplug. Fix that and combine the two code paths into one.

* src/qemu_driver.c: fix list updating in qemudDomainDetachNetDevice(),
  qemudDomainDetachPciDiskDevice() and qemudDomainDetachHostPciDevice()
2009-08-18 09:41:56 +01:00
Mark McLoughlin
331e1fcbee Re-name remote_internal.c:driver to remote_driver
Confused me when poking at another 'driver' variable in gdb which gcc
had optimized away

* src/remote_internal.c: rename driver to remote_driver
2009-08-18 09:41:56 +01:00
Mark McLoughlin
097c818bf0 Cosmetic change to 'virsh nodedev-list --tree' output
Maybe it's just me, but I try to select an item from the tree using
double-click and get annoyed when "+-" gets included in the selection.

* src/virsh.c: add a space between "+-" and the node device name
  in 'virsh nodedev-list --tree'
2009-08-18 09:41:56 +01:00
Chris Lalancette
cb51aa48a7 Fix up connection reference counting.
Currently the reference counting for connections is busted.  I
first noticed it while trying to use virConnectRef; it would
eventually cause a crash in the remote_internal driver, although
that was really just a victim.  Really, we should only call the
close callbacks on the methods when the references drop to 0.  To
accomplish this, move all of the close callbacks into
virUnrefConnect (since there are lots of internal users of that
function), and arrange for virConnectClose to call that.

V2: Make sure to drop the connection lock before we call the close
    callbacks, otherwise we could deadlock the daemon
V3: Fix up a crash when we got an error from one of the drivers

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-18 09:26:26 +02:00
Daniel P. Berrange
e403f8d43e Fix LXC driver crash when kernel doesn't support clone
* src/domain_conf.c: Make virDomainObjListFree a no-op if list
  is NULL
* src/domain_event.c: make virDomainEventCallbackListFree a no-op
  if event list is NULL
* src/lxc_driver.c: Log a message if LXC driver does not startup
  due to lacking kernel support
2009-08-17 16:20:57 +01:00
Chris Lalancette
2d6a581960 Compressed save image format for Qemu.
Implement a compressed save image format for qemu.  While ideally
we would have the choice between compressed/non-compressed
available to the libvirt API, unfortunately there is no "flags"
parameter to the virDomainSave() API.  Therefore, implement this
as a qemu.conf option.  gzip, bzip2, and lzma are implemented, and
it should be very easy to implement additional compression
methods.

One open question is if/how we should detect the compression
binaries.  One way to do it is to do compile-time setting of the
paths (via configure.in), but that doesn't seem like a great thing
to do.  My preferred solution is not to detect at all;
when we go to run the commands that need them, if they
aren't available, or aren't available in one of the standard paths,
then we'll fail.  That's also the solution implemented in this patch.

In the future, we'll have a more robust (managed) save/restore API,
at which time we can expose this functionality properly in the API.

V2: get rid of redundant dd command and just use >> to append data.
V3: Add back the missing pieces for the enum and bumping the save version.
V4: Make the compressed field in the save_header an int.
    Implement LZMA compression.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-17 09:00:19 +02:00
Mark McLoughlin
c106c8a18c Check active domain hostdevs before allowing PCI reset
If a PCI device reset causes other devices to be reset, allow it so long
as those other devices are note assigned to another active domain.

Note, we need to take the driver lock qemudNodeDeviceReset() because the
check function will iterate over the domain list.

* src/qemu_conf.c: add qemuCheckPciHostDevice() to iterate over active
  domains checking whether the affected device is assigned

* src/pci.[ch]: add pciDeviceEquals() helper
2009-08-14 08:31:11 +01:00
Mark McLoughlin
6318808270 Allow pciResetDevice() to reset multiple devices
When using a Secondary Bus Reset, all devices on the bus are reset.

Extend the pciResetDevice() API so that a 'check' callback can be
supplied which will verify that it is safe to reset the other devices
on the bus.

The virDomainObjPtr parameter is needed so that when the check function
iterates over the domain list, it can avoid double locking.

* src/pci.[ch]: add a 'check' callback to pciResetDevice(), re-work
  pciIterDevices() to pass the check function to the iter functions,
  use the check function in the bus iterator, return the first unsafe
  device from pciBusCheckOtherDevices() and include its details in
  the bus reset error message.

* src/qemu_driver.c, src/xen_uninified.c: just pass NULL as the
  check function for now
2009-08-14 08:31:11 +01:00
Mark McLoughlin
ebea341856 Improve PCI host device reset error message
Currently, if we are unable to reset a PCI device we return a fairly
generic 'No PCI reset capability available' error message.

Fix that by returning an error from the individual reset messages and
using that error to construct the higher level error mesage.

* src/pci.c: set errors in pciTryPowerManagementReset() and
  pciTrySecondaryBusReset() on failure; use those error messages
  in pciResetDevice(), or explain that no reset support is available
2009-08-14 08:31:11 +01:00
Mark McLoughlin
4035152a87 Reset and re-attach PCI host devices on guest shutdown
When the guest shuts down, we should attempt to restore all PCI host
devices to a sane state.

In the case of managed hostdevs, we should reset and re-attach the
devices. In the case of unmanaged hostdevs, we should just reset them.

Note, KVM will already reset assigned devices when the guest shuts
down using whatever means it can, so we are only doing it to cover the
cases the kernel can't handle.

* src/qemu_driver.c: add qemuDomainReAttachHostDevices() and call
  it from qemudShutdownVMDaemon()
2009-08-14 08:31:11 +01:00
Mark McLoughlin
64a6682b93 Allow PM reset on multi-function PCI devices
It turns out that a PCI Power Management reset only affects individual
functions, and not the whole device.

The PCI Power Management spec talks about resetting the 'device' rather
than the 'function', but Intel's Dexuan Cui informs me that it is
actually a per-function reset.

Also, Yu Zhao has added pci_pm_reset() to the kernel, and it doesn't
reject multi-function devices, so it must be true! :-)

(A side issue is that we could defer the PM reset to the kernel if we
could detect that the kernel has PM reset support, but barring version
number checks we don't have a way to detect that support)

* src/pci.c: remove the pciDeviceContainsOtherFunctions() check from
  pciTryPowerManagementReset() and prefer PM reset over bus reset
  where both are available

Cc: Cui, Dexuan <dexuan.cui@intel.com>
Cc: Yu Zhao <yu.zhao@intel.com>
2009-08-14 08:31:11 +01:00
Mark McLoughlin
d4528d9ac2 Detect KVM's PCI device assignment support
PCI device assignment is only supported in KVM's fork of qemu, so we
should really detect its availability and give a nice error if its
not supported.

* src/qemu_conf.[ch]: introduce QEMUD_CMD_FLAG_PCIDEVICE indicating
  that the -pcidevice command line option is available

* tests/*: update the tests
2009-08-14 08:31:11 +01:00
Mark McLoughlin
0c5b7b93a3 Add host PCI device hotplug support
Attaching a host PCI device to a qemu guest is done with a
straightforward 'pci_add auto host host=XX:XX.X' command.

Like with NIC and disk hotplug, we need to retain the guest PCI address
assigned by qemu so that we can use it for hot-unplug.

Identifying a device for detach is done using the host PCI address.

Managed mode is handled by detaching/resetting the device before
attaching it to the guest and re-attaching it after detaching it from
the guest.

* src/qemu_driver.c: add qemudDomainAttachHostPciDevice() and
  qemudDomainDetachHostPciDevice()

* src/domain_conf.h: add somewhere to store the guest PCI address

* src/domain_conf.c: handle formatting and parsing the guest PCI
  address
2009-08-14 08:31:10 +01:00
Mark McLoughlin
7636ef4630 Re-factor hostdev hotplug
Re-factor the hostdev hotplug code so that we can easily add PCI
hostdev hotplug to qemudDomainAttachHostDevice().

* src/qemu_driver.c: rename qemudDomainAttachHostDevice() to
  qemudDomainAttachHostUsbDevice(); make qemudDomainAttachHostDevice()
  handle all hostdev types

* src/libvirt_private.syms: export a couple of hostdev related
  ToString() functions
2009-08-14 08:31:10 +01:00
Daniel P. Berrange
19bac57b26 Make LXC / UML drivers robust against NUMA topology brokenness
Some kernel versions expose broken NUMA topology for some machines.
This causes the LXC/UML drivers to fail to start. QEMU driver was
already fixed for this problem

* src/lxc_conf.c: Log and ignore failure to populate NUMA info
* src/uml_conf.c: Log and ignore failure to populate NUMA info
* src/capabilities.c: Reset nnumaCell to 0 after freeing
2009-08-13 12:11:41 +01:00
Chris Lalancette
48de890392 Remove a duplicated assignment in Xen PCI parsing.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:32:50 +02:00
Chris Lalancette
09cbae6297 Fix up a few minor indentation issues.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:32:26 +02:00
Chris Lalancette
82bdf6d5ae Fix phyp escape_specialcharacters.
A couple of minor fixes to phyp escape_specialcharacters.  Make it
a static function (since it's only used in phyp/phyp_driver.c), and
make it take a dstlen parameter.  This paves the way for removing
strncpy in the future.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:32:03 +02:00
Chris Lalancette
701477e8c3 Make openvzGetVPSUUID take a len.
Minor fix to openvzGetVPSUUID to make it take a length parameter.
This ensures that it doesn't make assumptions about the length
of the UUID buffer, and paves the way for removal of strncpy in
the future.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:31:32 +02:00
Chris Lalancette
9be5773fbb Minor cleanup of error path for c_oneVmInfo.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:31:04 +02:00
Chris Lalancette
b216dd41d7 Fix up a whitespace in comments in src/console.c
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:30:19 +02:00
Chris Lalancette
7b0075a242 Fix up a stray whitespace in virHashGrow.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:29:59 +02:00
Chris Lalancette
d1ec4d7a5a Run 'cont' on successful migration finish.
As of qemu 0.10.6, qemu now honors the -S flag on incoming migration.
That means that when the migration completes, we have to issue a
'cont' command to get the VM running again.  We do it unconditionally
since it won't hurt on older qemu.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:29:10 +02:00
Chris Lalancette
3c7a12b416 Split virDomainMigrate into functions.
Re-factor virDomainMigrate to split out the version 1 and version 2
protocols into their own functions.  In reality, the two versions share
very little in common, so forcing them together in the same function was
just confusing.  This will also make adding tunnelled migration easier.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:27:54 +02:00
Chris Lalancette
cbcf5ba7d4 Fix QEMU domain status after restore.
When doing a restore, we were forgetting to update the state file
for the VM.  That means that if you do a save/restore, then shut
down libvirtd, then start it back up, you'll see the state of the
guest as "paused", even though it is really running.  We were
just forgetting a "virDomainSaveStatus" call in the restor path.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-11 13:27:07 +02:00
Mark McLoughlin
f5a8f969dd Handle kernels with no ipv6 support
If the ipv6 kernel module is not loaded, then we get this when starting
a virtual network:

  libvir: Network Config error :
  cannot enable /proc/sys/net/ipv6/conf/virbr0/disable_ipv6:
  No such file or directory

If disable_ipv6 is not present, we should just merrily continue on our
way.

* src/network_driver.c: make networkDisableIPV6() not fail if the kernel
  has no ipv6 support
2009-08-10 11:19:42 +01:00
Mark McLoughlin
c42b397845 chown kernel/initrd before spawning qemu
If we're running qemu unprivileged, we need to chown any supplied kernel
or initrd before spawning it.

* src/qemu_driver.c: rename qemuDomainSetDiskOwnership() to
  qemuDomainSetFileOwnership(), pass it a path string instead of a disk
  definition and use it for chowning the kernel/initrd in
  qemuDomainSetAllDeviceOwnership()
2009-08-10 09:00:01 +01:00
Chris Lalancette
47919e46ab Remove unsafe strncpy from esx_vmx.c
While trying to remove uses of unsafe strncpy in the tree, I came
across a couple of usages in the ESX driver.  To my eyes, the snprintf
replacements do the same thing in less code, and are also safer.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
Tested-by: Mattias Bolte <matthias.bolte@googlemail.com>
2009-08-07 13:50:32 +02:00
Amy Griffis
63fbcc6927 Consolidate code for parsing the logging env
* src/logging.c src/logging.h src/libvirt_private.syms:
  define new functions virLogSetFromEnv and virLogParseDefaultPriority
* qemud/qemud.c src/libvirt.c tests/eventtest.c: cleanup to use the
  unified functions
2009-08-06 15:55:07 +02:00
Amy Griffis
9147bf2a73 Several fixes to libvirtd's log setup
* qemud/qemud.c src/logging.[ch]: Similar as for general libvirt, don't
  convert high priority levels to debug level. Ignore LIBVIRT_LOG_FILTERS
  and LIBVIRT_LOG_OUTPUTS when they're set to the empty string, otherwise
  they can override a valid setting from the config file. Send all
  settings through the parser functions for validation, so that the
  existence of a bad setting doesn't nullify a good setting that should
  have applied -- particularly the default output. Keep the order of
  precedence consistent for all variables between the environment and
  the config file.  Warn when an invalid log level, filter, or output
  is ignored.
* src/libvirt_private.syms: export internally a few convenience functions
2009-08-06 15:45:50 +02:00
Amy Griffis
22a1ec68d5 Tighten libvirt's parsing of logging env
* src/libvirt.c src/logging.c: Don't convert high priority levels to the
  debug level. Don't parse LIBVIRT_LOG_FILTERS and LIBVIRT_LOG_OUTPUTS
  when they're set to the empty string. Warn when the user specifies an
  invalid value (empty string remains a noop).
* po/POTFILES.in: src/logging.c now include translatable strings
2009-08-06 15:38:11 +02:00
Matthias Bolte
a9e96b1ee0 Cleanup structure name naming
* src/esx/esx_driver.c src/esx/esx_util.[ch] src/esx/esx_vi.[ch]:
  just a name change
2009-08-06 15:15:45 +02:00
Matthias Bolte
5f48643e0a Fix memleak if esxOpen fails
* src/esx/esx_driver.c: if esxOpen failed, priv->transport wasn't freed
2009-08-06 15:09:40 +02:00
Matthias Bolte
a7c76142a0 Add proper OOM reporting for esxDomainGetOSType
* src/esx/esx_driver.c: catch an unchecked strdup in
  esxDomainGetOSType()
2009-08-06 15:07:46 +02:00
Ryota Ozaki
8b54ef4147 Add an allocation unit when calling qemu-img
* src/storage_backend.c: as the absence of units can be interpreted
  in diverging ways depending on the version
2009-08-05 14:35:17 +02:00
Daniel P. Berrange
a480572244 Add uniqness checking for LXC define/create methods
* src/lxc_driver.c: Check for name & UUID uniqueness when
  defining or creating domains
2009-08-05 12:01:04 +01:00
Daniel P. Berrange
388f3368cb Fix removal of transient VMs when LXC aborts
* src/lxc_driver.c: Remove transient VM after monitor triggered
  shutdown
2009-08-05 12:01:04 +01:00
Daniel P. Berrange
53d9a92497 Don't try to activate cgroups if not present for LXC
* src/lxc_controller.c: Don't throw error in LXC startup if
  the cgroups driver mount isn't available. Improve error
  logging for resource setup
2009-08-05 12:01:04 +01:00
Daniel P. Berrange
acec6c3d02 Avoid a warning if compiling without inotify
* src/xm_internal.c: split the implementations of xenInotifyActive()
2009-08-05 12:04:26 +02:00
Aron Griffis
3879b33447 Typo and comment fixes
* docs/schemas/*.rng: the comments were wrong
* src/qemu_conf.c: typo in an error message
2009-08-05 11:56:56 +02:00
Cole Robinson
a11010c07d Refresh /etc/xen if inotify wasn't
* src/xm_internal.c: in case of multiple connections to the xen driver
  and some clients were not using domain events, the whole /etc/xen
  monitoring would break leading to disapearing domains.
2009-08-05 11:46:33 +02:00
Cole Robinson
8ddfb40e2d Don't loose id on xen domain redefine
* src/xm_internal.c: bug when redefining a domain, if it was running
  we would loose its id
2009-08-05 11:39:31 +02:00
Daniel Veillard
3e64748c72 Remove a stray semicolon
* src/xend_internal.c: extraneous ; in xenDaemonParseSxprGraphicsNew
2009-08-05 11:24:23 +02:00
Maximilian Wilhelm
3f11d7820a Workaround for broken GCC in Debian Etch
* src/storage_conf.c src/internal.h: move previous check in internal.h
  and add a workaround for a GCC bug in Debian Etch on limit definitions
2009-08-05 11:19:34 +02:00
Matthias Bolte
10a4e969a6 Extend the ESX URL to habdle ports and GSX
* src/esx/esx_driver.c src/esx/esx_vi.[ch] src/esx/esx_vmx.[ch]:
  adds version checking for GSX 2.0, allows to pass a specific port
  for the connection and also add a new specific gsx scheme for
  easier connections to GSX hosts
2009-08-05 10:23:59 +02:00
Daniel P. Berrange
8feb499ba2 Fix escaping of 8-bit high characters
Fix  https://bugzilla.redhat.com/show_bug.cgi?id=479517

* src/buf.c: Cast to 'unsigned char' before doing compare to
  avoid rejecting 8-bit high characters
2009-08-04 18:13:09 +01:00
Daniel P. Berrange
bf69fd9b22 Fix memory leak in openvz driver
* src/openvz_driver.c: Remove unneccessary strdup() on hypervisor
  type api call
2009-08-03 11:42:39 +01:00
Chris Lalancette
7a4769bbdb Remove ATTRIBUTE_UNUSED from flags to qemudDomainMigratePerform.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:08:11 +02:00
Chris Lalancette
1fdb582a09 Add a comment about setting errors after qemudStartVMDaemon().
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:08:00 +02:00
Chris Lalancette
067c00f533 Fix an erroneous debug error to KVM; it should read QEMU/KVM.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:07:45 +02:00
Chris Lalancette
1a94521770 Remove a stray semicolon in qemudDomainMigratePrepare2.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:07:33 +02:00
Chris Lalancette
08cb0b3cfc Convert a few stray users of free() in libvirt.c to VIR_FREE().
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:07:20 +02:00
Chris Lalancette
180ca598c4 Use virGetHostname instead of gethostname.
Fix up qemudDomainMigratePrepare2 to use virGetHostname instead of
gethostname.  Besides the fact that virGetHostname is far more clever,
there was a latent bug in the handling that could cause a buffer overflow
on a very long hostname.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:07:02 +02:00
Chris Lalancette
f24d4671d4 Fix up a minor indentation issue with virDomainMigratePrepare.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:06:35 +02:00
Chris Lalancette
e1ec2a1ea6 Fix virCapabilitiesDefaultGuestMachine documentation.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-08-02 12:06:20 +02:00
Daniel P. Berrange
e170af3ac0 Protected against potential crash scenarios
* src/qemu_driver.c: Check that monitor device is not NULL
  before runing a command to protect against bugs in caller
2009-07-31 17:06:44 +01:00
Daniel P. Berrange
88e3e8be7c Improve diagnostics when pidfile writing fails
* src/util.c: Include path & pid when logging pidfile failure
2009-07-31 17:06:44 +01:00
Daniel P. Berrange
5d3e02aaa2 Fix crash when attempting to shutdown inactive QEMU vm
* src/qemu_driver.c: Add check that QEMU is active before attemting
  to shutdown. Fix error code for check in destroy method
2009-07-31 17:06:44 +01:00
Daniel P. Berrange
84e96866ac Enable ESX driver build on Mingw32
* autobuild.sh, mingw32-libvirt.spec.in: Enable esx on mingw32
* src/esx/esx_driver.c: Define AI_ADDRCONFIG if not set
* src/esx/esx_util.c, src/esx/esx_vi_types.c: Always use
  %lld & friends, since gnulib guarentees we have these
  and not the target's own variants
2009-07-31 16:15:51 +01:00
Daniel P. Berrange
651153216b Disable IPv6 on virtual networks
If the bridge device is configured to have IPv6 address and
accept router advertisments, then a malicious guest can send
out bogus advertisments and hijack/DOS host IPv6 connectivity

* src/network_driver.c: Set accept_ra=0, disable_ipv6=1, autoconf=0
  for IPv6 sysctl on virual network bridge devices
2009-07-31 16:14:26 +01:00
Mark McLoughlin
a49cf8a57d Fix PCIe FLR detection
PCIe DevCap register is actually 32 bits, not 16 bits. Since FLR is
bit 28, we clearly are failing to detect FLR support.

Known to fix device reset with some SR-IOV devices.

* src/pci.c: fix pciDetectFunctionLevelReset()
2009-07-31 15:41:36 +01:00
Daniel P. Berrange
9a152d481b Fix problem writing QEMU pidfile
* src/util.c: Don't drop capabilities until after the PID file has
  been written. Kill off child if writing the PID file fails
* src/qemu_driver.c: Remove bogus trailing '/' in state dir
2009-07-30 17:47:34 +01:00
Daniel P. Berrange
df3de82c06 Allow dnsmasq to provide DNS without DHCP
* src/network_driver.c: Always start dnsmasq to allow it to provide
  DNS, even if no DHCP ranges are enabled
2009-07-30 17:47:15 +01:00
Maximilian Wilhelm
8db5f642e9 Avoid warning when compiling without IFF_VNET_HDR
* src/bridge.c: avoid a couple of unused var/func warnings
2009-07-30 17:28:44 +02:00
Matthias Bolte
3f3ec73d39 ESX Scheduler documentation and cleanup
* esx/esx_driver.c: add some documentation about the CPU scheduler
  parameters and remove some old, unnecessary compensation code, since
  virsh uses the proposed parameter types now.
2009-07-30 13:41:04 +02:00
Henrik Persson
c9bece0c8f Fix vcpupin on Xen problem
* src/xend_internal.c: the update on the cpu affinity map format
  had na error and made the changes in the wrong buffer, fix those
2009-07-30 13:32:03 +02:00
Aron Griffis
d3209478d5 Fix an initialization problem in previous patch
* src/bridge.c: fix struct ifreq ifr init in brAddTap()
2009-07-30 09:14:47 +02:00
Aron Griffis
8fa592e3dc Remove MAX_TAP_ID and let kernel do numbering
* src/bridge.c: no need to format the device string in brAddTap()
  this can be delegated to the kernel and removes an arbitrary limit.
2009-07-29 23:23:23 +02:00
Ron Yorston
e195b43932 Kernel command line support for UML
* src/uml_conf.c: add support for additional kernel command line
  arguments.
2009-07-29 16:40:49 +02:00
Daniel P. Berrange
664085ab74 Fix deadlock in remote driver domain events
* src/remote_internal.c: Release driver lock when dispatching events
  to callbacks
2009-07-29 15:25:18 +01:00
Ryota Ozaki
abe3ee9cc5 qemu: fix monitor socket reconnection
* src/qemu_driver.c: fix qemudOpenMonitorUnix() to retry on ENOENT
  instead of EACCES which is the error one receive when the socket
  error hasn't shown up yet
2009-07-29 16:13:05 +02:00
Shahar Klein
5c153e200f Drop curl host check when using ESX without check
* src/esx/esx_vi.c: drop host check if no_verify=1, but as Matthias
  pointed out if no_verify=2 we should check the host is the right
  one
2009-07-28 12:13:20 +02:00
Daniel P. Berrange
dd6cd7dd63 Fix crashes in Xen capabilities code
* src/xen_internal.c: Don't free memory now owned by the virCapsPtr
   structure
* tests/testutilsxen.c: Fix up for change in internal API
2009-07-27 16:45:01 +01:00
Daniel P. Berrange
f055724b27 Fix typo in xen capabilities code 2009-07-27 16:31:24 +01:00
Daniel P. Berrange
c4a04dc024 Fill in vCPU <-> pCPU current mapping, and vCPU cpuTime for QEMU
* src/qemu_driver.c: implement missing features in qemudDomainGetVcpus
  for 'cpu' and 'cpuTime' fields
2009-07-27 16:30:25 +01:00
Mark McLoughlin
85453c4247 Add support for attaching network/bridge NICs in QEMU driver
In order to hotplug a network/bridge backed NIC, we need to first create
the tap file descriptor, add the tap interface to the bridge and then
pass the file descriptor to the qemu process using the 'getfd' monitor
command.

Once the tapfd has been accepted, we create the network backend using
host_net_add, supplying the name assigned to the tapfd. If this fails,
we need to close the tapfd in qemu using the 'closefd' monitor command.

If the version of qemu does not support the getfd/closefd monitor
commands we detect "unknown command" in the getfd reply and fail the
attach operation.

* src/qemu_driver.c: add support for tapfd based hotplug in
  qemudDomainAttachNetDevice()
2009-07-27 15:31:52 +01:00
Mark McLoughlin
1daaebfa0c Add SCM_RIGHTS support to QEMU monitor code
Add qemudMonitorCommandWithFd() which allows a file descriptor to be
sent to qemu over a unix monitor socket using SCM_RIGHTS. See the
unix(7) and cmsg(3) man pages.

* src/qemu_conf.c: add a scm_fd param to qemudMonitorCommandExtra(),
  add qemudMonitorCommandWithFd(), implement SCM_RIGHTS support in
  qemudMonitorSendUnix()
2009-07-27 15:31:51 +01:00
Mark McLoughlin
7d9576edcb Use sendmsg() on QEMU monitor socket
Switch from using write() to using sendmsg() on QEMU's monitor socket
so that we can add support for SCM_RIGHTS.

* src/qemu_driver.c: add sendmsg() based qemudMonitorSendUnix() and use
  it when the monitor fd is a unix socket
2009-07-27 15:31:51 +01:00
Mark McLoughlin
9de2972c30 Factor qemudMonitorSend() out of qemudMonitorCommandExtra()
Add a little helper function to write the monitor command followed by
carriage return in a single write.

This doesn't make any real difference, but allows us to more easily
switch to using sendmsg() when using the monitor over a unix socket.

* src/qemu_conf.c: split qemudMonitorSend() out
2009-07-27 15:31:51 +01:00
Mark McLoughlin
be44cabd7f Clean up error handling in qemudDomainAttachNetDevice()
In subsequent patches we're going to have a file descriptor to close
too, so centralize the error handling cleanups to make things easier.

* src/qemu_conf.c: in qemudDomainAttachNetDevice() consolidate the
  error handling cleanups together
2009-07-27 15:31:51 +01:00
Mark McLoughlin
32db8dd75b Make qemuBuildHostNetStr() take tapfd as a string
With hotplug, we're going to want to pass a tapfd name rather than an
actual file descriptor, so prepare the way by passing a string tapfd to
qemuBuildHostNetStr().

* src/qemu_conf.h: qemuBuildHostNetStr() takes a string tapfd now

* src/qemu_conf.c: pass qemuBuildHostNetStr() a string rather than an
  actual file descriptor

* src/qemu_driver.c: update qemudDomainAttachNetDevice() for change
2009-07-27 15:31:51 +01:00
Mark McLoughlin
a3f33b6531 Move vnet_hdr logic into qemudNetworkIfaceConnect() and export it
* src/qemu_conf.h: export qemudNetworkIfaceConnect()

* src/qemu_conf.c: move vnet_hdr logic into qemudNetworkIfaceConnect()
  since we need it for hotplug too
2009-07-27 15:31:51 +01:00
Mark McLoughlin
707302b2cf Only probe qemu for machine types when binary changes
By probing for qemu machine types, we increased the time of a
GetCapabilities call from 100us to a whopping 60ms.

This patch takes the approach of only probing for machine types
when the mtime of the emulator binary changed since the last time
the capabilities were generated.

* src/capabilities.h: cache the emulator binary mtime

* src/qemu_conf.c: add qemudGetOldMachines() to copy the machine
  types from the old caps struct if the mtime for the binary hasn't
  changed

* src/qemu_conf.h, src/qemu_driver.c: pass the old caps pointer to
  qemudCapsInit()
2009-07-27 15:30:35 +01:00
Mark McLoughlin
0f15d0344d Add canonical machine name to capabilities output
e.g. <machine canonical='pc'>pc-0.11</machine>

* src/capabilities.c: output the canonical machine names in the
  capabilities output, if available

* docs/schemas/capabilities.rng: add the new attribute
2009-07-27 15:30:17 +01:00
Mark McLoughlin
c14c6b083e Probe QEMU directly for machine aliases if not found in capabilties
Not all possible emulators are actually in the capabilities, so if we
don't find the supplied emulator we should probe it directly for machine
types.

* src/qemu_driver.c: add qemudCanonicalizeMachineDirect() to directly
  probe an emulator for the canonical machine type
2009-07-27 15:17:55 +01:00
Mark McLoughlin
be291b330a Canonicalize qemu machine types
In qemu-0.11 there is a 'pc-0.10' machine type which allows you to run
guests with a machine which is compatible with the pc machine in
qemu-0.10 - e.g. using the original PCI class for virtio-blk and
virtio-console and disabling MSI support in virtio-net. The idea here
is that we don't want to suprise guests by changing the hardware when
qemu is updated.

I've just posted some patches for qemu-0.11 which allows libvirt to
canonicalize the 'pc' machine alias to the latest machine version.

This patches makes us use that so that when a guest is configured to
use the 'pc' machine type, we resolve that to 'pc-0.11' machine and
save that in the guest XML.

See also:

  https://fedoraproject.org/wiki/Features/KVM_Stable_Guest_ABI

* src/qemu_conf.c: add qemudCanonicalizeMachine() to canonicalize
  the machine type according to the machine aliases in capabilities

* src/qemu_driver.c: parse aliases in qemudParseMachineTypesStr()
2009-07-27 15:17:55 +01:00
Mark McLoughlin
38fd207e53 Add virCapsGuestMachine structure
A subsequent commit will add a "canonical" field to this structure,
this patch basically just prepares the way for that.

The new type is added, along with virCapabilitiesAlloc/FreeMachines()
helpers and a whole bunch of code to make the transition.

One quirk is that virCapabilitiesAddGuestDomain() and
virCapabilitiesAddGuest() take ownership of the machine list rather
than duping it. This makes sense to avoid needless copying.

* src/capabilities.h: add the virCapsGuestMachine struct and use it
  in virCapsGuestDomainInfo, add prototypes for new functions and
  update the AddGuest() prototypes

* src/capabilities.c: add code for allocating and freeing the new
  type, change the machines parameter to AddGuest() etc.

* src/libvirt_private.syms: export the new helpers

* src/qemu_conf.c: update all the machine type code to use the new
  struct

* src/xen_internal.c: ditto

* tests/testutilsqemu.c: ditto
2009-07-27 15:17:55 +01:00
Mark McLoughlin
d412487eb7 Probe for QEMU machine types
Currently we hardcode the QEMU machine types. We should really just
parse the output of 'qemu -M ?' so the lists don't get out of sync.

xenner doesn't support '-M ?', so we still need to hardcode that.

The horrible (const char *const *) is removed in a subsequent patch.

* src/qemu_conf.c: kill the arch_info*machines tables, retain the
  hardcoded xenner machine type, add qemudProbeMachineTypes() to
  run and parse 'qemu -M ?' and use it in qemudCapsInitGuest()
2009-07-27 15:17:55 +01:00
Mark McLoughlin
7803e6f3ed Cleanup qemu binary detection logic in qemudCapsInitGuest()
There's no need for the hasbase/hasaltbase confusion, just store the
first binary path found in a variable.

* src/qemu_conf.c: kill hasbase/hasaltbase logic in qemudCapsInitGuest()
2009-07-27 15:17:55 +01:00
Matthias Bolte
84255632cb ESX driver accept VI API version 4.0
* src/esx/esx_driver.c src/esx/esx_vi.c src/esx/esx_vi.h
  src/esx/esx_vmx.c src/esx/esx_vmx.h: extend the VI API version checks
  to accept version 4.0 and takes care of the virtualHW.version change
  from 4 to 7.
2009-07-27 14:27:09 +02:00
Matthias Bolte
b557a36890 Allow leading dots in VMX config entry names
* src/conf.c: the virConfParser must accept leading dot when in VMX mode
2009-07-27 14:21:17 +02:00
Matthias Bolte
e4e50f52e8 Add no_verify query parameter to ESX URIs
* src/esx/esx_driver.c src/esx/esx_util.c src/esx/esx_util.h
  src/esx/esx_vi.c src/esx/esx_vi.h: adds a no_verify query parameter to
  stop libcurl from verifying theserver certificate for the https
  transport.
2009-07-27 14:18:25 +02:00
Matthias Bolte
e74d6c5009 Fix memory leaks in esxDomainDumpXML
* src/esx/esx_driver.c: remove leaks in esxDomainDumpXML() and simplify
  esxDomainXMLFromNative()
2009-07-27 14:13:11 +02:00
Cole Robinson
b4ad955d9e test: Implement BlockStats and InterfaceStats
We fake stats values based on the current time, similar to how it's done
for cpu time.
2009-07-26 17:26:15 -04:00
Cole Robinson
3b4a542c06 test: Generate net interface names when assigning XML.
We need interface names to implement InterfaceStats.
2009-07-26 17:25:46 -04:00
Cole Robinson
13f3d40cbf Don't allow NULL paths for BlockStats and InterfaceStats
Do the check in libvirt.c, to save drivers from the burden. This changes
behavior slightly in the qemu driver: we no longer explictly error if
passed an empty string. An error will still be thrown when the device
lookup fails.
2009-07-26 17:25:20 -04:00
Daniel P. Berrange
484640eaf6 Fix misc build problems due to new drivers
* autobuild.sh: Disable esx/phyp build on mingw32
* configure.in: Fix handling of --without-phyp so it actually works
* libvirt.spec.in: Add missing interface.rng
* mingw32-libvirt.spec.in: Disable phyp/esx drivers
* src/phyp/phyp_driver.c: Fix missing i18n of error messages
2009-07-24 17:20:50 +01:00
Pritesh Kothari
41e097e91a Add support for VBox 3 and event callbacks on vbox
* src/vbox/vbox_driver.c: remove some old 2.5 switches and plug the
  3.0 driver
* src/vbox/vbox_V3_0.c src/vbox/vbox_CAPI_v3_0.h: the driver for
  VirtualBox 3.0
* src/vbox/vbox_tmpl.c: handle the new driver and add event support
* src/Makefile.am: plug in the new module
2009-07-24 18:12:16 +02:00
Daniel P. Berrange
1112330e46 Fix cgroup compile warnings
* src/cgroup.c: Fix cast to uint64 from unsigned long long
2009-07-24 16:11:00 +01:00
Eduardo Otubo
a7a82f9889 First version of the Power Hypervisor driver
Features supported:
- Connects to HMC/VIOS or IVM systems.
- Life cycle commands (resume and shutdown).
- dumpxml
- 'list' and 'list --all'

What is being implemented:
- better and centralized control for UUID
- definexml
- CPU management commands

* src/domain_conf.c src/domain_conf.h: first version of the driver
* configure.in src/Makefile.am include/libvirt/virterror.h
  src/domain_conf.[ch] src/libvirt.c src/virterror.c: glue the driver
  in the general framework
2009-07-24 16:17:06 +02:00
Matthias Bolte
e2aeee6811 First version of the driver for VMWare ESX
* src/esx/esx_*.[ch]: the driver, uses a remote minimal SOAP client
  to talk to the VI services on ESX nodes.
* configure.in include/libvirt/virterror.h src/Makefile.am src/driver.h
  src/libvirt.c src/virterror.c: glue in the new driver
2009-07-23 22:25:34 +02:00
Daniel P. Berrange
f4c3acdf35 Make QEMU cgroups use configurable
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug,
   src/qemu.conf: Add 'cgroups_controllers' and 'cgroups_device_acl'
   parameters
 * src/qemu_conf.h, src/qemu_conf.c: Load & parse configuration params
   for cgroups
 * src/qemu_driver.c: Only use cgroups controllers that are activated,
   and use configured device whitelist instead of default, if set.
2009-07-23 17:38:06 +01:00
Daniel P. Berrange
e88d638ac6 Use cgroups for block device whitelisting in QEMU guests
* src/qemu_driver.c: Set a restrictive block device whitelist for
  all QEMU guests. Update whitelist when hotplugging disks.
* src/cgroup.h, src/cgroup.c: Add some more convenience methods
  for dealing with block device whitelists.
2009-07-23 17:38:06 +01:00
Daniel P. Berrange
55bc5090b9 Implement schedular tunables API using cgroups
* src/qemu_driver.c:  Add driver methods qemuGetSchedulerType,
  qemuGetSchedulerParameters, qemuSetSchedulerParameters
* src/lxc_driver.c: Fix to use unsigned long long consistently
  for schedular parameters
* src/cgroup.h, src/cgroup.c: Fix cpu_shares to take unsigned
  long long
* src/util.c, src/util.h, src/libvirt_private.syms: Add a
  virStrToDouble helper
* src/virsh.c: Fix handling of --set arg to schedinfo command
  to honour the designated data type of each schedular tunable
  as declared by the driver
2009-07-23 17:38:06 +01:00
Daniel P. Berrange
38f6f47be9 Place every QEMU guest in a private cgroup
* src/qemu_driver.c: Place guest in cgroup upon startup. Remove
  cgroup upon shutdown
2009-07-23 17:38:06 +01:00
Daniel P. Berrange
946c489c68 Refactor cgroups to allow a group per driver to be managed directly
Allow the driver level cgroup to be managed explicitly by the
hypervisor drivers, in order to detect whether to enable or
disable cgroup support for domains. Provides better error
reporting of failures. Also allow for creation of cgroups for
unprivileged drivers if controller is accessible by the user.

* src/cgroup.c, src/cgroup.h: Add an API to obtain a driver cgroup
* src/lxc_conf.h, src/lxc_controller.c, src/lxc_driver.c:
  Obtain a driver cgroup at startup and use that instead of
  re-creating everytime.
* src/util.c, src/util.h, src/libvirt_private.syms: Add a
  virGetUserName() helper
2009-07-23 17:38:06 +01:00
Daniel P. Berrange
de1ecd5302 Make cgroups a little more efficient
* src/cgroup.c: Detect the mount location of every controller at
  time a virCgroupPtr is created. Detect current process' placement
  within group to avoid assuming it is in the root. Pass controller
  ID into SetValueStr/GetValueStr to enable much duplicated code to
  be eliminated
2009-07-23 17:38:06 +01:00
Laine Stump
165ed4a00e Add bare format string to printf-derivatives troubles
* src/datatypes.c src/domain_conf.c src/interface_conf.c
  src/lxc_driver.c src/qemu_driver.c src/storage_backend.c src/virsh.c:
  add bare %s format string to printf-derivatives called with no format
  string
2009-07-23 18:27:47 +02:00
Daniel P. Berrange
ed5a25841f Don't restore labels on shared/readonly disks
* src/security_selinux.c: Skip relabelling of shared/readonly
  disks upon shutdown, since this breaks other VMs still active
  using those disks
2009-07-23 16:26:25 +01:00
Daniel P. Berrange
be18d3a732 Use virFileReadAll/virFileWriteStr for key cgroup read/write helpers 2009-07-23 16:20:13 +01:00
Daniel P. Berrange
6c5d4e7cf4 Use enums for cgroup controller types / labels 2009-07-23 16:19:31 +01:00
Daniel P. Berrange
5320ce02d8 Add domain autostart for LXC driver
* src/lxc_driver.c: Implement support for domain autostart
2009-07-23 16:11:35 +01:00
Daniel P. Berrange
9b5655a89e Add domain events support to LXC driver
* src/lxc_conf.h: Add queue for dispatch of domain events
* src/lxc_driver.c: Trigger domain events upon important lifecycle transitions
2009-07-23 16:11:26 +01:00
Daniel P. Berrange
899ae0d2b5 Fix misc Win32 compile warnings
GCC >= 4.4 assumes the 'printf' attribute refers to the native
runtime libraries format specifiers. Thanks to gnulib, libvirt
has GNU format specifiers everywhere.  This means we need to
use 'gnu_printf' with GCC >= 4.4 to get correct compiler
checking of printf format specifiers.

* HACKING: Document new rules for ATTRIBUTE_FMT_PRINTF
* autobuild.sh, mingw32-libvirt.spec.in: Disable OpenNebula
  driver on mingw32 builds
* qemud/dispatch.h, qemud/qemu.h, src/buf.h src/internal.h,
  src/logging.h, src/security.h, src/sexpr.h, src/util.h,
  src/virterror_internal.h, src/xend_internal.c: Change
  over to ATTRIBUTE_FMT_PRINTF.
* src/virsh.c: Disable 'cd' and 'pwd' commands on Win32
  since they don't compile
* src/threads-win32.c: Add missing return value check
2009-07-23 16:07:32 +01:00
Jim Paris
7922e247f1 Always add -no-kvm and -no-kqemu, for qemu domains
If the qemu binary supports "-no-kvm" and/or "-no-kqemu", they should
always be added for plain "qemu" domains.  Previously, we omitted them
whenever the host and guest architectures implied that they would be
disabled automatically, but that logic was flawed in some cases
(such as i686 and x86_64).
* src/qemu_conf.c: fix the conditions for adding "-no-kvm" and/or "-no-kqemu"
2009-07-22 20:51:28 +02:00
Laine Stump
647247740f Release conn lock before reporting errors (end)
* src/datatypes.c: more cleanup, where lock must be released before
  calling error handling which tries to get it.
2009-07-22 19:22:41 +02:00
Laine Stump
335f6bc251 Rename variable for compilation in Mingw32 (end)
* qemud/remote.c src/interface_conf.[ch] src/veth.[ch]: more renaming
  from interface to iface
2009-07-22 19:18:19 +02:00
Nguyen Anh Quynh
e4c48e02b4 Add support for physical memory access for QEmu
* include/libvirt/libvirt.h include/libvirt/libvirt.h.in: adds the new
  flag VIR_MEMORY_PHYSICAL for virDomainMemoryPeek
* src/libvirt.c: update the front-end checking
* src/qemu_driver.c: extend the QEmu driver
2009-07-22 16:29:38 +02:00
Laine Stump
528d37bdfe Release conn lock before reporting interface errors
* src/datatypes.c: fix a lock problem on error handling, as the
  error report takes the lock, it must be released before, fixes
  the problem but just for Interface objects
2009-07-22 16:15:52 +02:00
Laine Stump
fb1b7d8ed0 Update modified mac address in place in virGetInterface
* src/datatypes.c: handle the nasty case where an interface
  mac address change, while it's already in use
2009-07-22 16:07:26 +02:00
Laine Stump
d26d18a1a6 Fix multiple memory leaks in virsh
* virsh.c: fix a number of leaks of virDomain, virStoragePool,
  virNodeDevice, etc.
2009-07-22 15:46:16 +02:00
Daniel P. Berrange
2cc33bfe20 Fix typo in storage cloning 2009-07-22 12:40:02 +01:00
Mark McLoughlin
c2709cdaaa Add support for network device detach
qemu network devices are hot-unplugged in two stages - first the PCI NIC
is removed using 'pci_del <pci_addr>' and then the backend is removed
using 'host_net_remove <vlan> <name>'.

In order to perform these operations we need to have retained the
PCI address, backend name and vlan number.

* src/qemu_driver.c: add qemudDomainDetachNetDevice()
2009-07-22 11:34:07 +01:00
Mark McLoughlin
4e21a95afe Retain PCI address from NIC attach
When we pci_add a NIC, we need to retain the PCI address assigned by
qemu for using during detach.

* src/qemu_driver.c: use qemudParsePciAddReply() to pull the PCI
  address from the pci_add reply

* src/domain_conf.c: handle storing and parsing the PCI address in the
  domain state XML file
2009-07-22 11:34:07 +01:00
Mark McLoughlin
ffec099e75 Re-factor pci_add reply parsing and parse domain/bus numbers
The current code for parsing pci_add replies ignores the the domain and
bus numbers. Re-write the code to rectify that.

Also, since pci_add is used for NIC hotplug as well ask disk hotplug,
re-factor the code into a separate function.

* src/qemu_driver.c: add qemudParsePciAddReply() function which can
  handle parsing domain and bus numbers
2009-07-22 11:34:07 +01:00
Mark McLoughlin
d06f261cb1 Remove the network backend if NIC hotplug fails
If we fail to pci_add a NIC, we should remove the network backend and
leave things the way we found them. To do that, we pre-allocate a
host_net_remove monitor command and issue that if the pci_add fails.
If the remove fails, we just log a warning.

We can only do this if we have a name for the network backend and
we know the vlan number its associated with.

* src/qemu_driver.c: host_net_remove the network backend if the
  pci_add fails
2009-07-22 11:34:07 +01:00
Mark McLoughlin
35153940e3 Basic qemu NIC hotplug support
Implement basic NIC hotplug support using the 'host_net_add' and
'pci_add' qemu monitor commands.

For now, we don't support 'bridge' or 'network' types.

Also, if pci_add fails, we currently fail to remove the backend
which we added.

Finally, NIC hot-unplug support is missing.

* src/qemu_driver.c: add qemudDomainAttachNetDevice()

* src/qemu_conf.[ch]: export qemuBuildNicStr(), qemuBuildHostNetStr()
  and qemuAssignNames()

* src/libvirt_private.syms: export virDomainNetTypeToString()
2009-07-22 11:34:06 +01:00
Mark McLoughlin
423af1977f Make qemuCmdFlags available in qemudDomainAttachDevice()
qemudDomainChangeEjectableMedia() currently extracts the qemu command
line flags, but other device attaching code might need it, so move
the qemudExtractVersionInfo() call up a frame.

* src/qemu_driver.c: move the qemudExtractVersionInfo() call from
  qemudDomainChangeEjectableMedia() to qemudDomainAttachDevice()
2009-07-22 11:34:06 +01:00
Mark McLoughlin
30605477f2 Store the interface vlan number in the domain state
Currently, an interface's vlan number corresponds to its index in
the table of network interfaces. That is no longer true when we
allow devices to be removed.

To fix this, we store the vlan number in the domain's state XML
so that it survives libvirtd restarts.

* src/domain_conf.h: add vlan number to virDomainNetDef

* src/domain_conf.c: store it in XML as <state vlan='N'/>, defaulting
  to -1 if this is state saved by a previous version of libvirt

* src/qemu_conf.c: assign vlan numbers before starting qemu
2009-07-22 11:34:06 +01:00
Mark McLoughlin
36c820e6c8 Add NIC and hostnet names to domain state XML
The qemu driver needs to assign and keep track of identifiers for
network devices so that it can remove them. We need to keep this state
across libvirtd restarts, but it's not configuration that needs to
be kept across guest restarts.

* src/domain_conf.c: parse and format <state nic="foo" hostnet="bar"/>
2009-07-22 11:34:06 +01:00
Mark McLoughlin
c23dae4e5c Assign names to qemu NICs and network backends
We need these so that we can remove the devices via the monitor.

* src/domain_conf.h: add nic_name and hostnet_name to virDomainNetDef

* src/domain_conf.c: free nic_name and hostnet_name

* src/qemu_conf.c: add qemuAssignNetNames(), use it if qemu has
  support for the param and pass the names on the command line

* tests/qemuxml2argv*: add a test for this
2009-07-22 11:34:06 +01:00
Mark McLoughlin
948897687e Add checks for some NIC hotplug related features added in qemu-0.10.0
Add QEMUD_CMD_FLAG_NET_NAME to indicate that '-net ...,name=foo' is
supported and QEMUD_CMD_FLAG_HOST_NET_ADD to indicate that the
'host_net_add' monitor command is available.

Set both these flags if the qemu version is greater than 0.10.0.
Checking via the '-help' output would not work for the monitor command
and even for the command line arg, it would be quite fragile.

* src/qemu_conf.h: add new flags as aliases of QEMUD_CMD_FLAG_0_10

* src/qemu_conf.c: set QEMUD_CMD_FLAG_0_10 for versions >= 0.10.0

* tests/qemuhelptest.c: set QEMUD_CMD_FLAG_0_10 for the appropriate
  qemu versions
2009-07-22 11:34:06 +01:00
Mark McLoughlin
63e67ee013 Factor qemuBuildHostNetStr() out from qemuBuildCommandLine()
Re-factor this code so that it can be used for NIC hotplug
too. The awkward prefix and type_sep arguments are needed to
allow us to do "host_net_add tap vlan=..."

* src/qemu_conf.c: factor the net backend string formatting
  code into its own function
2009-07-22 11:34:06 +01:00
Mark McLoughlin
ce2e300a4f Factor qemuBuildNicStr() out from qemuBuildCommandLine()
Re-factor this code so that it can be used for NIC hotplug
too. The awkward arguments are needed to allow use to do
"pci_add auto nic macaddr=..."

* src/qemu_conf.c: factor the nic string formatting code into
  its own function
2009-07-22 11:34:06 +01:00
Mark McLoughlin
0165410712 Retain disk PCI address across libvirtd restarts
When we hot-plug a disk device into a qemu guest, we need to retain its
PCI address so that it can be removed again later. Currently, we do
retain the slot number, but not across libvirtd restarts.

Add <state devaddr="xxxx:xx:xx"/> to the disk device XML config when the
VIR_DOMAIN_XML_INTERNAL_STATUS flag is used. We still don't parse the
domain and bus number, but the format allows us to do that in future.

* src/domain_conf.h: replace slotnum with pci_addr struct, add helper
  for testing whether the address is valid

* src/domain_conf.c: handle formatting and parsing the address

* src/qemu_driver.c: store the parsed slot number as a full PCI address,
  and use this address with the pci_del monitor command

* src/vbox/vbox_tmpl.c: we're debug printing slotnum here even though
  it can never be set, just delete it
2009-07-22 11:34:05 +01:00
Mark McLoughlin
aa98871c77 Add internal XML parsing/formatting flag
We need to store things like device names and PCI slot numbers in the
qemu domain state file so that we don't lose that information on
libvirtd restart. Add a flag to indicate that this information should
be parsed or formatted.

Make bit 16 and above of the flags bitmask for internal use only and
consume the first bit for this new status flag.

* include/libvirt/libvirt.h: add VIR_DOMAIN_XML_FLAGS_MASK

* src/libvirt.c: reject private flags in virDomainGetXMLDesc()

* src/domain_conf.h: add VIR_DOMAIN_XML_INTERNAL_STATUS

* src/domain_conf.c: pass the flag from virDomainObjParseXML() and
  virDomainSaveStatus
2009-07-22 11:34:05 +01:00
Laine Stump
1499e1d5f4 Rename variable for compilation in Mingw32
* src/virsh.c: rename interface into iface
2009-07-22 10:32:03 +02:00
Thomas Treutner
683241de5a Fix documentation of virStoragePoolUndefine return
* src/libvirt.c: the documented return was wrong
2009-07-22 08:41:40 +02:00
Daniel P. Berrange
6c3f7d7fd6 Fix typo in check for glusterfs format pools
* src/storage_backend_fs.c: Replace = with == for comparison
2009-07-21 12:49:44 -04:00
Harshavardhana
44948f5b69 Set specific flags for glusterfs fs mounts
* src/storage_backend_fs.c: due to Fuse O_DIRECT problem one need
  to mount glusterfs with direct-IO mode, until fixed
2009-07-21 17:49:20 +02:00
Pritesh Kothari
e1506cb4eb Fix reconnect bug for VBox
* src/vbox/vbox_tmpl.c: reconnecting to vbox:///session was failing
2009-07-21 16:44:50 +02:00
Daniel Veillard
909d647aab Activate the interface drivers, and cleanups
* src/libvirt.c: activate the interface drivers
* po/POTFILES.in: add the netcf driver as a source of localization strings
* src/interface_driver.c: NETCF_ENOMEM -> VIR_ERR_NO_MEMORY mapping was
  breaking syntax checking
2009-07-21 16:15:39 +02:00
Laine Stump
da4f146f83 Netcf based interface driver implementation
* src/interface_driver.c src/interface_driver.h: the new driver
* src/Makefile.am qemud/Makefile.am qemud/qemud.c: hook the new driver
  in the build system and get ti activated by the daemon
* src/libvirt_private.syms: export needed symbols internally
2009-07-21 16:02:16 +02:00
Laine Stump
3edbc2c4a9 Add a test interface driver
* test.c: includes an interface driver to the test framework
2009-07-21 15:45:55 +02:00