Commit Graph

3699 Commits

Author SHA1 Message Date
Daniel P. Berrange
d78554d884 Specify bus/unit instead of index for disks with QEMU
The current code for using -drive simply sets the -drive 'index'
parameter. QEMU internally converts this to bus/unit depending
on the type of drive. This does not give us precise control over
the bus/unit assignment though. This change switches over to make
libvirt explicitly calculate the bus/unit number.

In addition bus/unit/index are actually irrelevant for VirtIO
disks, since each virtio disk is a separate PCI device. No disk
controller is involved.

Doing the conversion to bus/unit in libvirt allows us to correctly
attach SCSI controllers when required.

* src/qemu/qemu_conf.c: Specify bus/unit instead of index for
  disks
* tests/qemuxml2argvdata/qemuxml2argv-disk*.args: Switch over from
  using index=NNNN, to bus=NN, unit=NN for SCSI/IDE/Floppy disks
2010-01-15 17:55:59 +00:00
Daniel P. Berrange
2982d73a11 Split code for building QEMU -drive arg in separate method
To enable it to be called from multiple locations, split out
the code for building the -drive arg string. This will be needed
by later patches which do drive hotplug, the conversion to use
-device, and the conversion to controller/bus/unit addressing

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add qemuBuildDriveStr
  for building -drive arg string
2010-01-15 17:55:58 +00:00
Daniel P. Berrange
ab0da52b43 Convert monitor over to use virDomainDeviceAddress
Convert the QEMU monitor APIs over to use virDomainDeviceAddress
structs for passing addresses in/out, instead of individual bits.
This makes the number of parameters smaller & easier to deal with.
No functional change

* src/qemu/qemu_driver.c, src/qemu/qemu_monitor.c,
  src/qemu/qemu_monitor.h, src/qemu/qemu_monitor_text.c,
  src/qemu/qemu_monitor_text.h: Change monitor hotplug APIs to
  take an explicit address ptr for all host/guest addresses
2010-01-15 17:55:58 +00:00
Jim Fehlig
8d6af63a8a Minor fixes for API extension doc
Update the API Extensions doc to reflect new source directory layout.
2010-01-15 10:45:18 -07:00
Wolfgang Mauerer
74ec5e65ce Add new domain device: "controller"
This augments virDomainDevice with a <controller> element
that is used to represent disk controllers (e.g., scsi
controllers). The XML format is given by

  <controller type="scsi" index="<num>">
     <address type="pci" domain="0xNUM" bus="0xNUM" slot="0xNUM"/>
  </controller>

where type denotes the disk interface (scsi, ide,...), index
is an integer that identifies the controller for association
with disks, and the <address> element specifies the controller
address on the PCI bus as described in previous commits
The address element can be omitted; in this case, an address
will be assigned automatically.

Most of the code in this patch is from Wolfgang Mauerer's
previous disk controller series

 * docs/schemas/domain.rng: Define syntax for <controller>
   XML element
 * src/conf/domain_conf.c, src/conf/domain_conf.h: Define
   virDomainControllerDef struct, and routines for parsing
   and formatting XML
* src/libvirt_private.syms: Add virDomainControllerInsert
   and virDomainControllerDefFree
2010-01-15 16:38:59 +00:00
Daniel P. Berrange
776e37e1eb Set default disk controller/bus/unit props
When parsing the <disk> element specification, if no <address>
is provided for the disk, then automatically assign one based on
the <target dev='sdXX'/> device name. This provides for backwards
compatability with existing applications using libvirt, while also
allowing new apps to have complete fine grained control.

* src/conf/domain_conf.h, src/conf/domain_conf.c,
  src/libvirt_private.syms: Add virDomainDiskDefAssignAddress()
  for assigning a controller/bus/unit address based on disk target
* src/qemu/qemu_conf.c: Call virDomainDiskDefAssignAddress() after
  generating XML from ARGV
* tests/qemuxml2argvdata/*.xml: Add in drive address information
  to all XML files
2010-01-15 16:38:29 +00:00
Daniel P. Berrange
a9e4ea94f1 Add address info to sound, video and watchdog devices
Add the virDomainDeviceAddress information to the sound, video
and watchdog devices. This means all of them gain the new XML
element

  <address .... />

This brings them upto par with disk/net/hostdev devices which
already have address info

* src/conf/domain_conf.h: Add virDomainDeviceAddress to sound,
  video & watchdog device struts.
* src/conf/domain_conf.c: Hook up parsing/formatting for
  virDomainDeviceAddress in sound, video & watchdog devices
* docs/schemas/domain.rng: Associate device address info
  with sound, video & watchdog
2010-01-15 16:38:08 +00:00
Daniel P. Berrange
d812e7aeb8 Extend the virDomainDeviceAddress struture to allow disk controller addresses
Introduce a new structure

      struct _virDomainDeviceDriveAddress {
        unsigned int controller;
        unsigned int bus;
        unsigned int unit;
      };

and plug that into virDomainDeviceAddress and generates XML that
looks like

  <address type='drive' controller='1' bus='0' unit='5'/>

This syntax will be used by the QEMU driver to explicitly control
how drives are attached to the bus

* src/conf/domain_conf.h, src/conf/domain_conf.c: Parsing and
  formatting of drive addresses
* docs/schemas/domain.rng: Define new address format for drives
2010-01-15 16:37:57 +00:00
Daniel P. Berrange
1b0cce7d3a Introduce a standardized data structure for device addresses
All guest devices now use a common device address structure
summarized by:

  enum virDomainDeviceAddressType {
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
    VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
  };

  struct _virDomainDevicePCIAddress {
    unsigned int domain;
    unsigned int bus;
    unsigned int slot;
    unsigned int function;
  };

  struct _virDomainDeviceInfo {
    int type;
    union {
        virDomainDevicePCIAddress pci;
    } addr;
  };

This replaces the anonymous structs in Disk/Net/Hostdev data
structures. Where available, the address is *always* printed
in the XML file, instead of being hidden in the internal state
file.

  <address type='pci' domain='0x0000' bus='0x1e' slot='0x07' function='0x0'/>

The structure definition is based on Wolfgang Mauerer's disk
controller patch series.

* docs/schemas/domain.rng: Define the <address> syntax and
  associate it with disk/net/hostdev devices
* src/conf/domain_conf.h, src/conf/domain_conf.c,
  src/libvirt_private.syms: APIs for parsing/formatting address
  information. Also remove the QEMU specific 'pci_addr' attributes
* src/qemu/qemu_driver.c: Replace use of 'pci_addr' attrs with
  new standardized format.
2010-01-15 16:37:44 +00:00
Daniel P. Berrange
e8ac4a79f1 Make test suite output less verbose
Only print out '.' for each test case, full test output can be
re-enabled with VIR_TEST_VERBOSE=1, or VIR_TEST_DEBUG=XXXX

Sample output now looks like

  TEST: statstest
        ........................................ 40
        ...................................      75  OK
  PASS: statstest
  TEST: qparamtest
        ................................         32  OK
  PASS: qparamtest
  TEST:
        ............                             12  OK
2010-01-15 16:28:05 +00:00
Matthias Bolte
cfe49446d3 Fix compilation of virt-aa-helper.c
Commit 5073aa994a added an additional
'}' to a case block that messed up the block structure of the get_files
function.
2010-01-15 12:06:03 +01:00
Jim Meyering
0276587287 xen: do not report a write-to-Xen-daemon failure as a read failure
* src/xen/xend_internal.c (wr_sync): Correct the diagnostic.
2010-01-15 10:22:18 +01:00
Matthias Bolte
9933c4f2f6 Fix linkage of virt-aa-helper to libgnu.a 2010-01-14 21:50:21 +01:00
Cole Robinson
522776ed4c util: Make sure virExec hook failures are raised
With the introduction virDispatchError, hook function errors are
never sent through the error callback, so users will never see
these messages.

Fix this by calling virDispatchError after hook failure.
2010-01-14 09:19:39 -05:00
Cole Robinson
5073aa994a Implement path lookup for USB by vendor:product
Based off how QEMU does it, look through /sys/bus/usb/devices/* for
matching vendor:product info, and if found, use info from the surrounding
files to build the device's /dev/bus/usb path.

This fixes USB device assignment by vendor:product when running qemu
as non-root (well, it should, but for some reason I couldn't reproduce
the failure people are seeing in [1], but it appears to work properly)

[1] https://bugzilla.redhat.com/show_bug.cgi?id=542450
2010-01-13 15:24:41 -05:00
Cole Robinson
438fa79358 daemon: Don't blindly unregister domain events
The daemon will attempt to unregister domain events on client disconnect,
even if no events were ever registered. This raises an unneeded error.

Track in the qemu_client structure if events have been registered, and
check this when performing cleanup.
2010-01-13 14:24:13 -05:00
Cole Robinson
2d4d657695 daemon: Fix various error reporting issues
Many node device calls weren't properly relaying error messages, and
domain event registeration was not checking for error.
2010-01-13 14:24:13 -05:00
Cole Robinson
a3dddc0020 events: Report errors on failure 2010-01-13 14:24:07 -05:00
Cole Robinson
d0b97e820c node_device: udev: Fix memory leak
We are setting the same property two different ways without
free'ing in between. Just drop the second assignment.
2010-01-13 07:02:19 -05:00
Cole Robinson
c198f51a10 node_device: udev: Enumerate floppy devices
There are quite a few differences between how udev exposes legacy
and USB floppy devs, but this patch takes care of both variants.
2010-01-13 07:02:18 -05:00
Cole Robinson
3238081efd node_device: udev: Use base 16 for product/vendor
udev doesn't prefix USB product/vendor info with '0x', so the
strtol conversions were wrong for the product field (vendor already
set the correct base). Make the change for PCI product/vendor as
well to be safe.

This fixes USB device assignment via virt-manager.
2010-01-13 07:02:18 -05:00
Cole Robinson
2861390866 util: Remove logging handlers in virExec
This allows debug statements and raised errors in hook functions to
actually be logged somewhere (stderr). Users can enable debugging in the
daemon and now see more info in /var/log/libvirt/...
2010-01-13 07:02:10 -05:00
Jim Fehlig
6c6fbac7a9 Fix migration in xend driver
Upstream xen has changed parameters to the migration operation
several times over the past 18 months.  Changeset 17553 removed
the resouce parameter,  Changesets 17709, 17753, and 20326 added
ssl, node, and change_home_server parameters respectively.

Fortunately, testing has revealed that xend will fail the
operation if a parameter is missing but happily honor it if
unknown parameters are provided.  Thus all currently supported
parameters can be provided, satisfying current xend but not
regressing older versions.
2010-01-12 13:49:25 -07:00
Cole Robinson
515378b34e Commit bootstrap .gitignore additions 2010-01-12 14:36:11 -05:00
Cole Robinson
978dd6d48b qemu: Disable errors in qemudShutdownVMDaemon 2010-01-12 10:48:34 -05:00
Cole Robinson
e85065b854 libvirt.c: Preserve MigratePerform failure 2010-01-12 10:48:34 -05:00
Cole Robinson
a9d12c2444 qemu: migrate: Save MigratePerform error in MigrateFinish.
This way we won't squash the original error report in
MigratePerform, as is done for P2P and Tunneled migration.
2010-01-12 10:48:34 -05:00
Cole Robinson
fd5eb45b95 virterror: Add virSetError
Can be used to re-set an old error, which may have been squashed by
other functions (like cleanup routines). Will be used in subsequent patches
2010-01-12 10:48:33 -05:00
Daniel P. Berrange
3a80f2f7ce Ensure error handling callback functions are called from safe context
The virRaiseErrorFull() may invoke the error handler callback
functions an application has registered. This is not good
because the connection object may not be available at this
point, and the caller may be holding locks. This creates a
problem if the error handler calls back into libvirt.

The solutuon is to move invocation of the handler into the
final cleanup code in the public API entry points, where it
is guarenteed to have safe state.

* src/libvirt.c: Invoke virDispatchError() in all error paths
* src/util/virterror.c: Remove virSetConnError/virSetGlobalError,
  replacing with virDispatchError(). Move invocation of the
  error callbacks into virDispatchError() instead of the
  virRaiseErrorFull function which is not in a safe context
2010-01-12 10:48:33 -05:00
Daniel P. Berrange
66b3250563 Revert 7aee22939f
Revert commit 7aee22939f since it
is mistakenly adding an extra parameter to virsh that does not
belong there.
2010-01-12 12:48:34 +00:00
David Jorm
7aee22939f cpu_shares parameter limit documented 2010-01-12 12:24:04 +10:00
Matthias Bolte
ddcee85f7c Document the domain XML cache attribute for disk devices 2010-01-11 23:58:56 +01:00
Matthias Bolte
f01ee2acc8 qemu: Fix a memory leak in qemudExtractTTYPath
qemudWaitForMonitor calls qemudReadLogOutput with qemudFindCharDevicePTYs
as callback. qemudFindCharDevicePTYs calls qemudExtractTTYPath to assign
a string to chr->data.file.path. Afterwards qemudWaitForMonitor may call
qemudFindCharDevicePTYsMonitor that overwrites chr->data.file.path without
freeing the old value. This results in leaking the memory allocated by
qemudExtractTTYPath.

Report an OOM error if the strdup in qemudFindCharDevicePTYsMonitor fails.
2010-01-11 23:58:56 +01:00
Guido Günther
4c81b0fdc5 Also look for dmi information in /sys/class
older kernels such as 2.6.26 have it there.
2010-01-11 12:49:35 +01:00
Laine Stump
28024f2311 Fix UUID random generator to use /dev/random
Only use pseudo-random generator for uuid if using /dev/random fails.
* src/util/uuid.c: The original code. would only print the warning
  message if using /dev/random failed, but would still go ahead and call
  virUUIDGeneratePseudoRandomBytes in all cases anyway.
2010-01-11 10:06:54 +01:00
Jim Meyering
0418fa2e72 avoid another "make distcheck" failure
* docs/Makefile.am (uninstall-local): Separate $$f from preceding
dir name with a "/" and use $$(basename $$f) rather than $$f, since
some values of $$f are prefixed with devhelp/.
2010-01-09 09:56:20 +01:00
Jim Meyering
a4e9edbd77 avoid newly-introduced test failure
* tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Update
expected output to match, now that we use -mem-prealloc.
2010-01-09 09:25:04 +01:00
Jim Meyering
8287bd2996 proxy_internal.c: mark "request" parameter as nonnull
* src/xen/proxy_internal.c (xenProxyCommand): Mark "request"
as an always-non-NULL parameter.
2010-01-09 08:50:15 +01:00
Jim Meyering
3b3cdec395 don't test "res == NULL" after we've already dereferenced "res"
* src/xen/proxy_internal.c (xenProxyCommand): "res" is known to be
non-NULL at that point, so remove the "res == NULL" guard.
2010-01-09 08:50:15 +01:00
Jim Meyering
e6abf3d8f2 fix 7 "make check" test failures in non-srcdir build
* tests/capabilityschematest: Define and use $srcdir.
* tests/domainschematest: Likewise.
* tests/interfaceschematest: Likewise.
* tests/networkschematest: Likewise.
* tests/nodedevschematest: Likewise.
* tests/storagepoolschematest: Likewise.
* tests/storagevolschematest: Likewise.
2010-01-09 08:37:22 +01:00
Jim Meyering
048781fe71 let "configure --disable-shared" work once again
Without this change, ./autogen.sh --disable-shared && make would
evoke a "can not build a shared library" failure for libvirtmod.la
due to the new use of libtool's -shared link option in
python/Makefile.am.  Now, --disable-shared also
disables building python.

* configure.in: Make --disable-shared imply --without-python and
silently override --with-python.
Improved by: Diego Elio Pettenò <flameeyes@gmail.com>
2010-01-08 20:54:11 +01:00
Matthias Bolte
7003390791 esx: Dump the raw response in case of an SOAP fault
Currently only the faultcode and faultstring are deserialized, the
detail part is ignored. The implementation of many new SOAP types
would be necessary to deserialize the detail part correctly. As an
intermediate solution the raw response is dumped to the debug log.
2010-01-08 19:28:14 +01:00
Matthias Bolte
75b7f400f9 esx: Warn if the ESX server is in maintenance mode 2010-01-08 19:28:09 +01:00
Matthias Bolte
728e9229b1 Replace old CVS references with GIT 2010-01-08 18:08:22 +01:00
Daniel Veillard
edcae5a7c4 Qemu: ask for memory preallocation with large pages
The -mem-prealloc flag should be used when using large pages
This ensures qemu tries to allocate all required memory immediately,
rather than when first used. The latter mode will crash qemu
if hugepages aren't available when accessed, while the former
should gracefully fallback to non-hugepages.

* src/qemu/qemu_conf.c: add -mem-prealloc flag to qemu command line
  when using large pages
2010-01-08 12:17:35 +01:00
Jim Fehlig
98ea78b6ee xen hypervisor: xen domctl version 6
xen-unstable c/s 20685 changed the domctl interface, adding a field to
xen_domctl_getdomaininfo structure.  This additional field causes stack
corruption in libvirt.  xen-unstable c/s 20711 rightly bumped the domctl
interface version so it is at least possible to handle the new field.
This change accounts for shr_pages field added to xen_domctl_getdomaininfo
structure.
2010-01-07 13:05:35 -07:00
Jim Meyering
65160f50be network/bridge_driver.c: avoid potential NULL-dereference
* src/network/bridge_driver.c (networkBuildDnsmasqArgv): Correct
test for NULL *argv.
2010-01-07 14:25:45 +01:00
Matthias Bolte
b6c87e3b7a virsh: Use VIR_FREE instead of free
virsh uses other parts of the internal API already, so use VIR_FREE also.
2010-01-07 01:38:19 +01:00
Matthias Bolte
a4a38ffda1 virsh: Add persistent history using libreadline 2010-01-07 01:38:19 +01:00
Matthias Bolte
96ceb12443 esx: Fix 'vpx' MAC address range and allow arbitrary MAC addresses
The MAC addresses with 00:50:56 prefix are split into several ranges:

  00:50:56:00:00:00 - 00:50:56:3f:ff:ff  'static' range (manually assigned)
  00:50:56:80:00:00 - 00:50:56:bf:ff:ff  'vpx' range (assigned by a VI Client)

Erroneously the 'vpx' range was assumed to be larger and to occupy the
remaining addresses of the 00:50:56 prefix that are not part of the 'static'
range.

00:50:56 was used as prefix for generated MAC addresses, this is not possible
anymore, because there are gaps in the allowed ranges. Therefore, change the
prefix to 00:0c:29 which is the prefix for auto generated MAC addresses anyway.

Allow arbitrary MAC addresses to be used and set the checkMACAddress VMX option
to false in case the MAC address doesn't fall into any predefined range.

* docs/drvesx.html.in: update website accordingly
* src/esx/esx_driver.c: set the auto generation prefix to 00:0c:29
* src/esx/esx_vmx.c: fix MAC address range handling and allow arbitrary MAC
  addresses
* tests/vmx2xml*, tests/xml2vmx*: add some basic MAC address range tests
2010-01-07 01:38:19 +01:00