Commit Graph

3778 Commits

Author SHA1 Message Date
David Allan
6aabcb5bd8 Implement support for multi IQN
Allows the initiator to use a variety of IQNs rather than just the
system IQN when creating iSCSI pools.
* docs/schemas/storagepool.rng: extends the syntax with <iqn name="..."/>
* src/conf/storage_conf.[ch]: read and stores the iqn name
* src/storage/storage_backend_iscsi.[ch]: implement the IQN selection
  when detected
2010-01-21 12:50:52 +01:00
Jiri Denemark
39d883bb3d Let make fail when XHTML validation fails
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2010-01-21 09:45:59 +01:00
Laine Stump
623bc48ad8 Fix uses of virFileMakePath
* src/lxc/lxc_container.c src/lxc/lxc_controller.c src/lxc/lxc_driver.c
  src/network/bridge_driver.c src/qemu/qemu_driver.c
  src/uml/uml_driver.c: virFileMakePath returns 0 for success, or the
  value of errno on failure, so error checking should be to test
  if non-zero, not if lower than 0
2010-01-21 00:52:13 +01:00
Laine Stump
62927dd8f0 Create storage pool directories with proper uid/gid/mode
Previously the uid/gid/mode in the xml was ignored when creating new
storage pool directories. This commit attempts to honor the requested
permissions, and spits out an error if it can't.

Note that when creating the directory, the rest of the path leading up
to the final element is created using current uid/gid/mode, and the
final element gets the settings from xml. It is NOT an error for the
directory to already exist; in this case, the perms for the existing
directory are just set (if necessary).

* src/storage/storage_backend_fs.c: update the virStorageBackendFileSystemBuild
  function to check the directory hierarchy separately then create the
  leaf directory with the right attributes
2010-01-21 00:46:32 +01:00
Laine Stump
e1f2778434 Create storage volumes directly with desired uid/gid
In order to avoid problems trying to chown files that were created by
root on a root-squashing nfs server, fork a new process that setuid's
to the desired uid before creating the file. (It's only done this way
if the pool containing the new volume is of type 'netfs', otherwise
the old method of creating the file followed by chown() is used.)

This changes the semantics of the "create_func" slightly - previously
it was assumed that this function just created the file, then the
caller would chown it to the desired uid. Now, create_func does both
operations.

There are multiple functions that can take on the role of create_func:

createFileDir - previously called mkdir(), now calls virDirCreate().
virStorageBackendCreateRaw - previously called open(),
                             now calls virFileCreate().
virStorageBackendCreateQemuImg - use virRunWithHook() to setuid/gid.
virStorageBackendCreateQcowCreate - same.
virStorageBackendCreateBlockFrom - preserve old behavior (but attempt
                                   chown when necessary even if not root)

* src/storage/storage_backend.[ch] src/storage/storage_backend_disk.c
  src/storage/storage_backend_fs.c src/storage/storage_backend_logical.c
  src/storage/storage_driver.c: change the create_func implementations,
  also propagate the pool information to be able to detect NETFS ones.
2010-01-21 00:41:52 +01:00
Laine Stump
98f6f381c8 New utility functions virFileCreate and virDirCreate
These functions create a new file or directory with the given
uid/gid. If the flag VIR_FILE_CREATE_AS_UID is given, they do this by
forking a new process, calling setuid/setgid in the new process, and
then creating the file. This is better than simply calling open then
fchown, because in the latter case, a root-squashing nfs server would
create the new file as user nobody, then refuse to allow fchown.

If VIR_FILE_CREATE_AS_UID is not specified, the simpler tactic of
creating the file/dir, then chowning is is used. This gives better
results in cases where the parent directory isn't on a root-squashing
NFS server, but doesn't give permission for the specified uid/gid to
create files. (Note that if the fork/setuid method fails to create the
file due to access privileges, the parent process will make a second
attempt using this simpler method.)

If the bit VIR_FILE_CREATE_ALLOW_EXIST is set in the flags, an
existing file/directory will not cause an error; in this case, the
function will simply set the permissions of the file/directory to
those requested. If VIR_FILE_CREATE_ALLOW_EXIST is not specified, an
existing file/directory is considered (and reported as) an error.

Return from both of these functions is 0 on success, or the value of
errno if there was a failure.

* src/util/util.[ch]: add the 2 new util functions
2010-01-21 00:33:43 +01:00
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