Commit Graph

3822 Commits

Author SHA1 Message Date
Laine Stump
d2259ada49 Add virRunWithHook util function
* src/util/util.[ch]: similar to virExecWithHook, but waits for child to
  exit. Useful for doing things like setuid after the fork but before the
  exec.
2010-01-21 00:30:36 +01:00
Matthias Bolte
1671b64702 Unset copied environment variables in qemuxml2argvtest
The test expected all environment variables copied in qemudBuildCommandLine
to have known values. So all of them have to be either set to a known value
or be unset. SDL_VIDEODRIVER and QEMU_AUDIO_DRV are not handled at all but
should be handled. Unset both, otherwise the test will fail if they are set
in the testing environment.

* src/qemu/qemu_conf.c: add a comment about copied environment variables
  and qemuxml2argvtest
* tests/qemuxml2argvtest.c: unset SDL_VIDEODRIVER and QEMU_AUDIO_DRV
2010-01-20 23:22:15 +01:00
Matthias Bolte
aef969499f qemu: Don't allocate zero bytes 2010-01-20 22:50:35 +01:00
Jim Meyering
21c84e00d3 clean-up: remove unnecessary closedir call
* src/node_device/node_device_linux_sysfs.c (get_virtual_functions_linux):
Remove unnecessary closedir.  Spotted by Dave Allan.
2010-01-20 21:57:34 +01:00
Jim Meyering
2355fce3ae node_device_linux_sysfs.c: avoid opendir/fd leak on error path
* src/node_device/node_device_linux_sysfs.c(get_virtual_functions_linux):
Don't leak a DIR buffer and file descriptor on error path.
2010-01-20 21:52:51 +01:00
Jim Meyering
1825c6555a domain_conf.c: avoid a leak and the need for "cleanup:" block
* src/conf/domain_conf.c (virDomainChrDefFormat): Plug a leak on
an error path, and at the same time, eliminate the need for a
"cleanup:" block.  Before, the "return -1" after the switch
would leak an "addr" string.  Now, by reversing the port,addr-
getting blocks we can free "addr" immediately and skip the goto.
2010-01-20 21:46:30 +01:00
Daniel P. Berrange
50b6c95d62 Make all bitfields unsigned ints to avoid unexpected values in casts
The 'int virInterfaceIsActive()' method was directly returning the
value of the 'int active:1' bitfield in virIntefaceDefPtr. A bitfield
with a signed integer, will hold the values 0 and -1, not 0 and +1
as might be expected. This meant that virInterfaceIsActive() was
always returning -1 when the interface was active, not +1 & thus all
callers thought an error had occurred. To protect against this kind
of mistake again, change all bitfields to be unsigned ints

* daemon/libvirtd.h, src/conf/domain_conf.h, src/conf/interface_conf.h,
  src/conf/network_conf.h: Change bitfields to unsigned int.
2010-01-20 16:33:02 +00:00
Daniel P. Berrange
ed00e45dba Fix QEMU driver custom domain status XML extensions
Invoking the virConnectGetCapabilities() method causes the QEMU
driver to rebuild its internal capabilities object. Unfortunately
it was forgetting to register the custom domain status XML hooks
again.

To avoid this kind of error in the future, the code which builds
capabilities is refactored into one single method, which can be
called from all locations, ensuring reliable rebuilds.

* src/qemu/qemu_driver.c: Fix rebuilding of capabilities XML and
  guarentee it is always consistent
2010-01-20 16:33:02 +00:00
Jiri Denemark
704bd732b5 Document cpu-compare command in virsh man page
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-20 16:23:05 +01:00
Jiri Denemark
f0088c1bfa Document <cpu> elements in capabilities and domain XML
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-20 11:04:01 +01:00
Matthias Bolte
d392f4db9d docs: Remove outdated information about remote limitations 2010-01-20 10:03:17 +01:00
Jim Meyering
eb895e7407 logging: confirm that we want to ignore a write error
* src/util/logging.c (virLogMessage): Include "ignore-value.h".
Use it to ignore the return value of safewrite.
Use STDERR_FILENO, rather than "2".
* bootstrap (modules): Add ignore-value.
* gnulib: Update to latest, for ignore-value that is now LGPLv2+.
2010-01-19 21:28:41 +01:00
Jim Meyering
8cfc4c9a03 xen_driver: don't leak a parsed-config buffer
* src/xen/xen_driver.c (xenUnifiedDomainXMLFromNative): Also
free "conf" before returning.
2010-01-19 21:28:41 +01:00
Laine Stump
77dd67087b Update interface.rng and xml test files to match netcf 0.1.5
The RNG now supports IPv6 and bonds attached to bridges, along with
some other minor tweaks. All test files from netcf have been copied to
the test directory and added to the xml2xml and schema tests (and they
all pass, of course ;-)
2010-01-19 21:13:03 +01:00
Laine Stump
0022995555 Support bond interfaces attached to bridges in interface xml.
This was accomplished in xml parsing by doing away with the
stripped-down virInterfaceBareDef object, and just always using
virInterfaceDef, but with restrictions in certain places (eg, the type
of subordinate interface allowed in parsing depends on the parent
interface).

xml formatting was similarly adjusted. In addition, the formatting
functions keep track of the level of interface nesting, and insert
extra leading spaces on each line accordingly (using %*s).

The only change in formatted xml from previous (aside frmo supporting
new combinations of interface types) is that the subordinate ethernet
interfaces take up 2 lines rather than one, eg:

   <interface type='ethernet' name='eth0'>
   </interface>

instead of:

   <interface type='ethernet' name='eth0'/>
2010-01-19 21:13:03 +01:00
Laine Stump
86304e35a3 Allow empty bridges in interface xml. 2010-01-19 21:13:03 +01:00
Laine Stump
d22591efb9 Support delay property in interface bridge xml. 2010-01-19 21:13:03 +01:00
Jim Meyering
3aa13a471a storage_conf: plug a leak on OOM error path
* src/conf/storage_conf.c (virStoragePoolSourceListNewSource):
Free just-allocated "source" upon VIR_REALLOC_N failure.
2010-01-19 18:19:13 +01:00
Jiri Denemark
4bc3bd7b18 Remove superfluous new lines from messages
I noticed some debug messages are printed with an empty lines after
them. This patch removes these empty lines from all invocations of the
following macros:
    VIR_DEBUG
    VIR_DEBUG0
    VIR_ERROR
    VIR_ERROR0
    VIR_INFO
    VIR_WARN
    VIR_WARN0

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 17:30:41 +01:00
Jiri Denemark
a3e1f04b76 Use pciDeviceIsAssignable in qemu driver
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 17:30:41 +01:00
Jiri Denemark
379eb3956c Tests for ACS in PCIe switches
New pciDeviceIsAssignable() function for checking whether a given PCI
device can be assigned to a guest was added. Currently it only checks
for ACS being enabled on all PCIe switches between root and the PCI
device. In the future, it could be the right place to check whether a
device is unbound or bound to a stub driver.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 17:30:41 +01:00
Daniel Veillard
2c2672bc9a Add Jiri Denemark <jdenemar@redhat.com> to commiters 2010-01-19 14:41:19 +01:00
Jiri Denemark
ce4896fb65 Allow for CPU topology specification without model
Currently CPU topology may only be specified together with CPU model:
    <cpu match='exact'>
        <model>name</model>
        <topology sockets='1' cores='2' threads='3'/>
    </cpu>

This patch allows for CPU topology specification without the need for
also specifying CPU model:
    <cpu>
        <topology sockets='1' cores='2' threads='3'/>
    </cpu>

'match' attribute and 'model' element are made optional with the
restriction that 'match' attribute has to be set when 'model' is
present.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 12:35:22 +01:00
Jiri Denemark
16a4d22b4b Add debug messages for CPU incompatibility
When comparing incompatible CPUs, the reason for this incompatibility is
logged as a debug message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 12:33:14 +01:00
Jiri Denemark
5e13b7ab5e Take disabled/forced CPU features into account
When comparing x86 CPUs, features with 'disabled' policy were mistakenly
required to be supported by the host CPU.

Likewise, features with 'force' policy which were supported by host CPU
would make CPUs incompatible if 'strict' match was used by guest CPU.

This patch fixes both issues.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 12:29:29 +01:00
Jiri Denemark
5d462bd0b3 Implement CPU topology support for QEMU driver
QEMU's command line equivalent for the following domain XML fragment
    <vcpus>2</vcpus>
    <cpu ...>
        ...
        <topology sockets='1' cores='2', threads='1'/>
    </cpu>

is

    -smp 2,sockets=1,cores=2,threads=1

This syntax was introduced in QEMU-0.12.

Version 2 changes:
- -smp argument build split into a separate function
- always add ",sockets=S,cores=C,threads=T" to -smp if qemu supports it
- use qemuParseCommandLineKeywords for command line parsing

Version 3 changes:
- ADD_ARG_LIT => ADD_ARG and line reordering in qemudBuildCommandLine
- rebased

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 11:40:09 +01:00
Jiri Denemark
014c9f3196 Enhance qemuParseCommandLineKeywords
Current version expects name=value,... list and when an incorrect string
such as "a,b,c=d" would be parsed as "a,b,c" keyword with "d" value
without reporting any error, which is probably not the expected
behavior.

This patch adds an extra argument called allowEmptyValue, which if
non-zero will permit keywords with no value; "a,b=c,,d=" will be parsed
as follows:
    keyword value
    "a"     NULL
    "b"     "c"
    ""      NULL
    "d"     ""

In case allowEmptyValue is zero, the string is required to contain
name=value pairs only; retvalues is guaranteed to contain non-NULL
pointers. Now, "a,b,c=d" will result in an error.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-19 11:23:03 +01:00
Daniel P. Berrange
b66924148a Convert VirtIO balloon over to -device syntax
Replace

   -balloon virtio

With

   -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3

This allows it to get correct assigned PCI address as declared in
previous patch

 * src/qemu/qemu_conf.c: Convert Virtio ballon to -device and
   give it an explicit PCI address
 * tests/qemuxml2argvdata/qemuxml2argv-*args: Add in virtio balloon
   where appropriate
2010-01-18 13:55:57 +00:00
Daniel P. Berrange
a44d0dc26c Auto-assign PCI addresses
Instead of relying on QEMU to assign PCI addresses and then querying
them with 'info pci', manually assign all PCI addresses before starting
the guest.  These addresses are not stable across reboots. That will
come in a later patch

NB, the PIIX3 (IDE, FDC, ISA-Bridge) will always have slot 1 and
VGA will always have slot 2. We declare the Virtio Balloon gets
slot 3, and then all remaining slots are for configured devices.

* src/qemu/qemu_conf.c: If -device is supported, then assign all PCI
  addresses when building the command line
* src/qemu/qemu_driver.c: Don't query monitor for PCI addresses if
  they have already been assigned
* tests/qemuxml2argvdata/qemuxml2argv-hostdev-pci-address-device.args,
  tests/qemuxml2argvdata/qemuxml2argv-net-virtio-device.args,
  tests/qemuxml2argvdata/qemuxml2argv-sound-device.args,
  tests/qemuxml2argvdata/qemuxml2argv-watchdog-device.args: Update
  to include PCI slot/bus information
2010-01-18 13:55:57 +00:00
Daniel P. Berrange
febc591683 Pass -vga none if no video card specified
QEMU always configures a VGA card. If no video card is included in
the libvirt XML, it is neccessary to explicitly turn off the default
using -vga none

* src/qemu/qemu_conf.c: Pass -vga none if no video card is configured
* tests/qemuargv2xmltest.c, tests/qemuxml2argvtest.c: Test for
  handling -vga none.
* tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.args,
  tests/qemuxml2argvdata/qemuxml2argv-nographics-vga.xml: Test
  data files
2010-01-18 13:55:57 +00:00
Daniel P. Berrange
4f6c999006 Add support for explicit -sdl flag to QEMU
Not all QEMU builds default to SDL graphics for their display.
Newer QEMU now has an explicit -sdl flag, which we can use to
explicitly request SDL intead of relying on the default. This
protects libvirt against unexpected changes in graphics default

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Probe for -sdl
  flag and use it if it is found
* tests/qemuhelptest.c: Add SDL flag to tests
2010-01-18 13:55:57 +00:00
Daniel P. Berrange
d86c876a66 Convert guestfwd to -device, and add -sdl explicit args
The old syntax was

   -chardev SOMECONFIG
   -nic user,guestfwd=tcp:IP:PORT-chardev:CHARDEV

The new syntax is

   -chardev SOMECONFIG
   -netdev user,guestfwd=tcp:IP:PORT,chardev=ID,id=user-ID
2010-01-18 13:55:57 +00:00
Daniel P. Berrange
16658da4e7 Convert PCI device assignment over to -device
The old syntax is

  -pcidevice host=BUS:SLOT:FUNCTION

The new syntax is

  -device pci-assign,host=BUS:SLOT:FUNCTION,addr=<PCI SLOT>,id=host0
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
e8d43d0687 Convert USB input devices to -device 2010-01-18 13:55:56 +00:00
Daniel P. Berrange
42ce352c13 Convert USB hostdevices over to -device
The old syntax was

   -usbdevice host:PRODUCT:VENDOR

Or

   -usbdevice host:BUS.DEV

The new syntax is

   -device usb-host,product=PRODUCT,vendor=VENDOR

Or

   -device usb-host,hostbus=BUS,hostaddr=DEV
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
73370e9868 Convert USB disks over to -device
The previous syntax was severely limited in its options

  -usbdevice disk:/home/berrange/output.img

The new syntax is the same as for other disk types

  -drive file=/home/berrange/output.img,if=none,id=usb-1,index=1
  -device usb-storage,drive=usb-1

Again, the index= arg is wrong here, and will be removed in a
later merge
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
1dd6f855c3 Convert NICs over to use -device & -netdev where possible
The current syntax uses a pair of args

   -net nic,macaddr=52:54:00:56:6c:55,vlan=3,model=pcnet,name=pcnet.0
   -net user,vlan=3,name=user.0

The new syntax does not  need the vlan craziness anymore, and
so has a simplified pair of args

   -netdev user,id=user.0
   -device pcnet,netdev=user.0,id=pcnet.0,mac=52:54:00:56:6c:55,addr=<PCI SLOT>
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
6237e9c89b Convert disk drive over to use -device where available
The current preferred syntax for disk drives uses

  -drive file=/vms/plain.qcow,if=virtio,index=0,boot=on,format=qcow

The new syntax splits this up into a pair of linked args

  -drive file=/vms/plain.qcow,if=none,id=drive-virtio-0,format=qcow2
  -device virtio-blk-pci,drive=drive-virtio-0,id=virtio-0,addr=<PCI SLOT>

SCSI/IDE devices also get a bus property linking them to the
controller

  -device scsi-disk,drive=drive-scsi0-0-0,id=scsi0-0-0,bus=scsi0.0,scsi-id=0
  -device ide-drive,drive=drive-ide0-0-0,id=ide0-0-0,bus=ide0,unit=0
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
4886cba76a Convert audio devices over to -device syntax
The current syntax for audio devices is a horrible multiplexed
arg

    -soundhw sb16,pcspk,ac97

The new syntax is

    -device sb16,id=sound0

or

    -device AC97,id=sound1,addr=<PCI SLOT>

NB, pcspk still uses the old -soundhw syntax
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
38a22fbfaa Convert watchdog to -device
The current syntax for watchdogs is

    -watchdog i6300esb

The new syntax will now be

    -device i6300esb,id=watchdogNN,addr=<PCI-SLOT>
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
7b2f8cdd7c Convert character devices over to use -device
The current character device syntax uses either

  -serial tty,path=/dev/ttyS2

Or

  -chardev tty,id=serial0,path=/dev/ttyS2 -serial chardev:serial0

With the new -device support, we now prefer

  -chardev file,id=serial0,path=/tmp/serial.log -device isa-serial,chardev=serial0

This patch changes the existing -chardev syntax to use this new
scheme, and fallbacks to the old plain -serial syntax for old
QEMU.

The monitor device changes to

  -chardev socket,id=monitor,path=/tmp/test-monitor,server,nowait -mon chardev=monitor

In addition, this patch adds --nodefaults, which kills off the
default serial, parallel, vga and nic devices. THis avoids the
need for us to explicitly turn each off
2010-01-18 13:55:56 +00:00
Daniel P. Berrange
053307175c Assign device aliases for all devices at startup
When starting a guest, give every device a unique alias. This will
be used for the 'id' parameter in -device args in later patches.
It can also be used to uniquely identify devices in the monitor

For old QEMU without -device, assign disk names based on QEMU's
historical naming scheme.

* src/qemu/qemu_conf.c: Assign unique device aliases
* src/qemu/qemu_driver.c: Remove obsolete qemudDiskDeviceName
  and use the device alias in eject & blockstats commands
2010-01-18 13:55:56 +00:00
Jim Meyering
a6e7ba9464 storage_backend_fs.c: do not ignore probe failure
* src/storage/storage_backend_fs.c (virStorageBackendFileSystemRefresh):
Correct parentheses.  The documented intent is to ignore non-regular
files, yet due to a parenthesization error all errors were handled
that way.
2010-01-18 14:46:51 +01:00
Daniel P. Berrange
1ed1bf3a38 Probe for -device and use -nodefaults
Probe for the new -device flag and if available set the -nodefaults
flag, instead of using -net none, -serial none or -parallel none.
Other device types will be converted to use -device in later patches.
The -nodefaults flag will help avoid unwelcome surprises from future
QEMU releases

* src/qemu/qemu_conf.c: Probe for -device. Add -nodefaults flag.
  Remove -net none, -serial none or -parallel none
* src/qemu/qemu_conf.h: Define QEMU_CMD_FLAG_DEVICE
* tests/qemuhelpdata/qemu-0.12.1: New data file for 0.12.1 QEMU
* tests/qemuhelptest.c: Test feature extraction from 0.12.1 QEMU
2010-01-18 13:39:14 +00:00
Daniel P. Berrange
4ac290cc33 Add device info to serial, parallel, channel, input & fs devices
Although the serial, parallel, chanel, input & fs devices do
not have PCI address info, they can all have device aliases.
Thus it neccessary to associate the virDomainDeviceInfo data
with them all.

* src/conf/domain_conf.c, src/conf/domain_conf.h: Add hooks for
  parsing / formatting device info for serial, parallel, channel
  input and fs devices.
* docs/schemas/domain.rng: Associate device info with character
  devices, input & fs device
2010-01-18 13:38:56 +00:00
Daniel P. Berrange
5da9c98067 Introduce device aliases
This patch introduces the support for giving all devices a short,
unique name, henceforth known as a 'device alias'.  These aliases
are not set by the end user, instead being assigned by the hypervisor
if it decides it want to support this concept.

The QEMU driver sets them whenever using the -device arg syntax
and uses them for improved hotplug/hotunplug. it is the intent
that other APIs (block / interface stats & device hotplug) be
able to accept device alias names in the future.

The XML syntax is

   <alias name="video0"/>

This may appear in any type of device that supports device info.

* src/conf/domain_conf.c, src/conf/domain_conf.h: Add a 'alias'
  field to virDomainDeviceInfo struct & parse/format it in XML
* src/libvirt_private.syms: Export virDomainDefClearDeviceAliases
* src/qemu/qemu_conf.c: Replace use of "nic_name" field with the
  standard device alias
* src/qemu/qemu_driver.c: Clear device aliases at shutdown
2010-01-18 13:38:47 +00:00
Daniel P. Berrange
774c757e67 Clear assigned PCI devices at shutdown
The PCI device addresses are only valid while the VM is running,
since they are auto-assigned by QEMU. After shutdown they must
all be cleared. Future QEMU driver enhancement will allow for
persistent PCI address assignment

* src/conf/domain_conf.h, src/conf/domain_conf.c, src/libvirt_private.syms
  Add virDomainDefClearPCIAddresses() method for wiping out auto assigned
  PCI addresses
* src/qemu/qemu_driver.c: Clear PCI addresses at VM shutdown
2010-01-18 13:35:51 +00:00
Daniel P. Berrange
b030084f07 Auto-add disk controllers based on defined disks
Existing applications using libvirt are not aware of the disk
controller concept. Thus, after parsing the <disk> definitions
in the XML, it is neccessary to create <controller> elements
to satisfy all requested disks, as per their defined drive
addresses

* src/conf/domain_conf.c, src/conf/domain_conf.h,
  src/libvirt_private.syms: Add virDomainDefAddDiskControllers()
  method for populating disk controllers, and call it after
  parsing disk definitions.
* src/qemu/qemu_conf.c: Call virDomainDefAddDiskControllers()
  when doing ARGV -> XML conversion
* tests/qemuxml2argvdata/qemuxml2argv*.xml: Add disk controller
  data to all data files which don't have it already
2010-01-18 13:35:40 +00:00
Daniel P. Berrange
2224989c39 Avoid free'ing a constant string in chardev lookup code
* src/qemu/qemu_monitor_text.c: Don't free const string in
   qemuMonitorTextGetPtyPaths()
2010-01-18 13:33:50 +00:00
Daniel P. Berrange
4359900ed1 Remove restriction on duplicated sound devices in parser
It is perfectly acceptable to have multiple sound devices of
same type in guest configuration. If the underlying hypervisor
does not like this, it is its job to complain, not the XML
parser's

* src/conf/domain_conf.c: Remove hack which deleted duplicated
  sound device models.
* tests/xml2sexprdata/xml2sexpr-fv-sound.xml: Remove duplicate
  models
2010-01-18 12:44:50 +00:00