]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
11 years agoqemu: Add hotplug support for scsi host device
Han Cheng [Fri, 3 May 2013 18:07:31 +0000 (02:07 +0800)]
qemu: Add hotplug support for scsi host device

This adds both attachment and detachment support for scsi host
device.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat>
11 years agoFix starting domains when kernel has no cgroups support
Jim Fehlig [Fri, 10 May 2013 18:05:00 +0000 (12:05 -0600)]
Fix starting domains when kernel has no cgroups support

Found that I was unable to start existing domains after updating
to a kernel with no cgroups support

  # zgrep CGROUP /proc/config.gz
  # CONFIG_CGROUPS is not set
  # virsh start test
  error: Failed to start domain test
  error: Unable to initialize /machine cgroup: Cannot allocate memory

virCgroupPartitionNeedsEscaping() correctly returns errno (ENOENT) when
attempting to open /proc/cgroups on such a system, but it was being
dropped in virCgroupSetPartitionSuffix().

Change virCgroupSetPartitionSuffix() to propagate errors returned by
its callees.  Also check for ENOENT in qemuInitCgroup() when determining
if cgroups support is available.

11 years ago.gitignore: add fchosttest
Ján Tomko [Mon, 13 May 2013 15:16:54 +0000 (17:16 +0200)]
.gitignore: add fchosttest

11 years agoqemu: Refactor helpers for USB device attachment
Osier Yang [Fri, 3 May 2013 18:07:30 +0000 (02:07 +0800)]
qemu: Refactor helpers for USB device attachment

It's better to put the usb related codes into qemuDomainAttachHostUsbDevice
instead of qemuDomainAttachHostDevice.

And in the old qemuDomainAttachHostDevice, just stealing the "usb" from
driver->activeUsbHostdevs leaks the memory.

11 years agoEscaping leading '.' in cgroup names
Daniel P. Berrange [Fri, 3 May 2013 19:56:50 +0000 (20:56 +0100)]
Escaping leading '.' in cgroup names

Escaping a leading '.' with '_' in the cgroup names

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: Introduce activeScsiHostdevs list for scsi host devices
Han Cheng [Fri, 3 May 2013 18:07:29 +0000 (02:07 +0800)]
qemu: Introduce activeScsiHostdevs list for scsi host devices

Although virtio-scsi supports SCSI PR (Persistent Reservations),
the device on host may do not support it. To avoid losing data,
Just like PCI and USB pass through devices, only one live guest
is allowed per SCSI host pass through device."

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
11 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/vbox/*
Michal Privoznik [Fri, 3 May 2013 12:50:19 +0000 (14:50 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/vbox/*

11 years agoSupport NBD backed disks/filesystems in LXC driver
Daniel P. Berrange [Mon, 22 Apr 2013 14:06:18 +0000 (15:06 +0100)]
Support NBD backed disks/filesystems in LXC driver

The LXC driver can already configure <disk> or <filesystem>
devices to use the loop device. This extends it to also allow
for use of the NBD device, to support non-raw formats.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd 'nbd' as a valid filesystem driver type
Daniel P. Berrange [Mon, 22 Apr 2013 14:06:17 +0000 (15:06 +0100)]
Add 'nbd' as a valid filesystem driver type

The <filesystem> element can now accept a <driver type='nbd'/>
as an alternative to 'loop'. The benefit of NBD is support
for non-raw disk image formats.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a helper API for setting up a NBD device with qemu-nbd
Daniel P. Berrange [Mon, 22 Apr 2013 14:06:16 +0000 (15:06 +0100)]
Add a helper API for setting up a NBD device with qemu-nbd

Add a virFileNBDDeviceAssociate method, which given a filename
will setup a NBD device, using qemu-nbd as the server.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix error handling of readdir() in virFileLoopDeviceOpen
Daniel P. Berrange [Fri, 3 May 2013 13:26:56 +0000 (14:26 +0100)]
Fix error handling of readdir() in virFileLoopDeviceOpen

To correctly handle errors from readdir() you must set 'errno'
to zero before invoking it & check its value afterwards to
distinguish error from EOF.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRe-arrange code setting up ifs/disk loop devices for LXC
Daniel P. Berrange [Mon, 22 Apr 2013 14:06:15 +0000 (15:06 +0100)]
Re-arrange code setting up ifs/disk loop devices for LXC

The current code for setting up loop devices to LXC disks first
does a switch() based on the disk format, then looks at the
disk driver name. Reverse this so it first looks at the driver
name, and then the disk format. This is more useful since the
list of supported disk formats depends on what driver is used.

The code for setting loop devices for LXC fs entries also needs
to have the same logic added, now the XML schema supports this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd support for storage format in FS <driver>
Daniel P. Berrange [Mon, 22 Apr 2013 14:06:14 +0000 (15:06 +0100)]
Add support for storage format in FS <driver>

Extend the <driver> element in filesystem devices to
allow a storage format to be set. The new attribute
uses 'format' to reflect the storage format. This is
different from the <driver> element in disk devices
which use 'type' to reflect the storage format. This
is because the 'type' attribute on filesystem devices
is already used for the driver backend, for which the
disk devices use the 'name' attribute. Arggggh.

Anyway for disks we have

   <driver name="qemu" type="raw"/>

And for filesystems this change means we now have

   <driver type="loop" format="raw"/>

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agosecurity_apparmor.c: Include virscsi.h
Michal Privoznik [Mon, 13 May 2013 12:01:14 +0000 (14:01 +0200)]
security_apparmor.c: Include virscsi.h

After introducing AppArmorSetSecuritySCSILabel() in 2691cd5f
we are using virSCSIDevicePtr type without proper include.

11 years agosecurity: Manage the security label for scsi host device
Osier Yang [Fri, 3 May 2013 18:07:28 +0000 (02:07 +0800)]
security: Manage the security label for scsi host device

To not introduce more redundant code, helpers are added for
both "selinux", "dac", and "apparmor" backends.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat>
v2.5 - v3:
  * Splitted from 8/10 of v2.5
  * Don't forget the other backends (DAC, and apparmor)

11 years agoqemu: Allow the scsi-generic device in cgroup
Han Cheng [Fri, 3 May 2013 18:07:27 +0000 (02:07 +0800)]
qemu: Allow the scsi-generic device in cgroup

This adds the scsi-generic device into the device controller's
whitelist, so that it's allowed to used by the qemu process.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agoqemu: Support bootindex for scsi host device
Osier Yang [Fri, 3 May 2013 18:07:26 +0000 (02:07 +0800)]
qemu: Support bootindex for scsi host device

11 years agoAdd docs about cgroups layout and usage
Daniel P. Berrange [Fri, 3 May 2013 15:58:26 +0000 (16:58 +0100)]
Add docs about cgroups layout and usage

Describe the new cgroups layout, how to customize placement
of guests and what virsh commands are used to access the
parameters.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoIntroduce <readonly> for hostdev
Osier Yang [Fri, 3 May 2013 18:07:25 +0000 (02:07 +0800)]
Introduce <readonly> for hostdev

Since it's generic enough to be used by other types in future, I
put it in <hostdev> as sub-element, though now it's only used by
scsi host device.

11 years agorng: Interleave hostdev elements
Osier Yang [Fri, 3 May 2013 18:07:24 +0000 (02:07 +0800)]
rng: Interleave hostdev elements

11 years agoqemu: Build qemu command line for scsi host device
Han Cheng [Fri, 3 May 2013 18:07:23 +0000 (02:07 +0800)]
qemu: Build qemu command line for scsi host device

Except the scsi host device's controller is "lsilogic", mapping
between the libvirt attributes and scsi-generic properties is:

  libvirt     qemu
-----------------------------------------
  controller  bus ($libvirt_controller.0)
  bus         channel
  target      scsi-id
  unit        lun

For scsi host device with "lsilogic" controller, the mapping is:
('target (libvirt)' must be 0, as it's not used; 'unit (libvirt)
must <= 7).

  libvirt            qemu
----------------------------------------------------------
  controller && bus  bus ($libvirt_controller.$libvirt_bus)
  unit               scsi-id

It's not good to hardcode/hard-check limits of these attributes,
and even worse, these limits are not documented, one has to find
out by either testing or reading the qemu code, I'm looking forward
to qemu expose limits like these one day). For example, exposing
"max_target", "max_lun" for megasas:

static const struct SCSIBusInfo megasas_scsi_info = {
    .tcq = true,
    .max_target = MFI_MAX_LD,
    .max_lun = 255,

    .transfer_data = megasas_xfer_complete,
    .get_sg_list = megasas_get_sg_list,
    .complete = megasas_command_complete,
    .cancel = megasas_command_cancel,
};

Example of the qemu command line (lsilogic controller):

  -drive file=/dev/sg2,if=none,id=drive-hostdev-scsi_host7-0-0-0 \
  -device scsi-generic,bus=scsi0.0,scsi-id=8,\
  drive=drive-hostdev-scsi_host7-0-0-0,id=hostdev-scsi_host7-0-0-0

Example of the qemu command line (virtio-scsi controller):

  -drive file=/dev/sg2,if=none,id=drive-hostdev-scsi_host7-0-0-0 \
  -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=128,lun=128,\
  drive=drive-hostdev-scsi_host7-0-0-0,id=hostdev-scsi_host7-0-0-0

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agoutils: util functions for scsi hostdev
Han Cheng [Fri, 3 May 2013 18:07:22 +0000 (02:07 +0800)]
utils: util functions for scsi hostdev

This patch adds util functions for scsi hostdev.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agoqemu: New cap flags for scsi-generic
Han Cheng [Fri, 3 May 2013 18:07:21 +0000 (02:07 +0800)]
qemu: New cap flags for scsi-generic

Adding two cap flags for scsi-generic:
  QEMU_CAPS_SCSI_GENERIC
  QEMU_CAPS_SCSI_GENERIC_BOOTINDEX

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agonode_device: Clean up unused macros
Osier Yang [Mon, 13 May 2013 10:09:54 +0000 (18:09 +0800)]
node_device: Clean up unused macros

All of these macros are now unused, so remove.

11 years agoconf: Generic XMLs for scsi hostdev
Han Cheng [Fri, 3 May 2013 18:07:20 +0000 (02:07 +0800)]
conf: Generic XMLs for scsi hostdev

An example of the scsi hostdev XML:

    <hostdev mode='subsystem' type='scsi'>
      <source>
        <adapter name='scsi_host0'/>
        <address bus='0' target='0' unit='0'/>
      </source>
      <address type='drive' controller='0' bus='0' target='4' unit='8'/>
    </hostdev>

Controller is implicitly added for scsi hostdev, though the scsi
controller's model defaults to "lsilogic", which might be not what
the user wants (same problem exists for virtio-scsi disk). It's
the existing problem, will be addressed later.

The device address must be specified manually. Later patch will let
libvirt generate it automatically.

This only introduces the generic XMLs for scsi hostdev, later patches
will add other elements, e.g. <readonly>, <shareable>.

Signed-off-by: Han Cheng <hanc.fnst@cn.fujitsu.com>
Signed-off-by: Osier Yang <jyang@redhat.com>
11 years agotests: Add tests for fc_host
Osier Yang [Mon, 6 May 2013 12:45:17 +0000 (20:45 +0800)]
tests: Add tests for fc_host

Since the NPIV machine is not easy to get, it's very likely to
introduce regressions when doing changes on the existing code.
This patch dumps part of the sysfs files (the necessary ones)
of fc_host as test input data, to test the related util functions.
It could be extended for more fc_host related testing in future.

11 years agoutil: Honor the passed sysfs_prefix
Osier Yang [Mon, 6 May 2013 12:45:16 +0000 (20:45 +0800)]
util: Honor the passed sysfs_prefix

The helper works for default sysfs_prefix, but for user specified
prefix, it doesn't work. (Detected when writing test cases. A later
patch will add the test cases for fc_host).

11 years agoutil: Update the comment for virGetFCHostNameByWWN
Osier Yang [Mon, 6 May 2013 12:45:15 +0000 (20:45 +0800)]
util: Update the comment for virGetFCHostNameByWWN

The returned result is something like "host5" acutally.

11 years agoutil: Change virIsCapable* to return bool
Osier Yang [Mon, 6 May 2013 12:45:14 +0000 (20:45 +0800)]
util: Change virIsCapable* to return bool

Function name with "aIsB" generally means its return value is
in Bi-state (true/false).

11 years agoutil: Don't miss the slash in constructed path
Osier Yang [Mon, 6 May 2013 12:45:13 +0000 (20:45 +0800)]
util: Don't miss the slash in constructed path

In case of the caller can pass a "prefix" (or "sysfs_prefix")
without the trailing slash, and Unix-Like system always eats
up the redundant "slash" in the filepath, let's add it explicitly.

11 years agoutil: Fix regression introduced by commit 4360a098441
Osier Yang [Mon, 6 May 2013 12:45:12 +0000 (20:45 +0800)]
util: Fix regression introduced by commit 4360a098441

Which refactored the old code, and introduced new helper
virIsCapableVport, but the path for checking with access() is not
correctly constructed.

11 years agoutil: Fix regression of wwn reading
Osier Yang [Mon, 6 May 2013 12:45:11 +0000 (20:45 +0800)]
util: Fix regression of wwn reading

Introduced by commit 244ce462e29, which refactored the helper for wwn
reading, however, it forgot to change the old "strndup" and "sizeof(buf)",
"sizeof(buf)" operates on the fixed length array ("buf") in the old code,
but now "buf" is a pointer.

Before the fix:

% virsh nodedev-dumpxml scsi_host5
<device>
  <name>scsi_host5</name>
  <parent>pci_0000_04_00_1</parent>
  <capability type='scsi_host'>
    <host>5</host>
    <capability type='fc_host'>
      <wwnn>2001001b</wwnn>
      <wwpn>2101001b</wwpn>
      <fabric_wwn>2001000d</fabric_wwn>
    </capability>
  </capability>
</device>

With the fix:

% virsh nodedev-dumpxml scsi_host5
<device>
  <name>scsi_host5</name>
  <parent>pci_0000_04_00_1</parent>
  <capability type='scsi_host'>
    <host>5</host>
    <capability type='fc_host'>
      <wwnn>0x2001001b32a9da4e</wwnn>
      <wwpn>0x2101001b32a9da4e</wwpn>
      <fabric_wwn>0x2001000dec9877c1</fabric_wwn>
    </capability>
  </capability>
</device>

11 years agobuild: fix use of mmap
Eric Blake [Sat, 11 May 2013 02:46:36 +0000 (20:46 -0600)]
build: fix use of mmap

Commit bfe7721d introduced a regression, but only on platforms
like FreeBSD that lack posix_fallocate and where mmap serves as
a nice fallback for safezero.

util/virfile.c: In function 'safezero':
util/virfile.c:837: error: 'PROT_READ' undeclared (first use in this function)

* src/util/virutil.c (includes): Move use of <sys/mman.h>...
* src/util/virfile.c (includes): ...to the file that uses mmap.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: update to latest gnulib, for syntax-check
Eric Blake [Sat, 11 May 2013 02:43:50 +0000 (20:43 -0600)]
build: update to latest gnulib, for syntax-check

This picks up a fix for a syntax-check weakness mentioned here:
https://www.redhat.com/archives/libvir-list/2013-May/msg00811.html

* .gnulib: Update to latest, for maint.mk improvement.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoUpdate hellolibvirt to demo virGetLastErrorMessage()
Daniel P. Berrange [Fri, 10 May 2013 17:43:38 +0000 (18:43 +0100)]
Update hellolibvirt to demo virGetLastErrorMessage()

Update the hellolibvirt example program to demonstrate use of
the virGetLastErrorMessage() API for quick error reporting

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a test case for the fdstream file read/write code
Daniel P. Berrange [Fri, 10 May 2013 17:14:40 +0000 (18:14 +0100)]
Add a test case for the fdstream file read/write code

Add a test case which exercises the virFDStreamOpenFile
and virFDStreamCreateFile methods. Ensure that both the
synchronous and non-blocking iohelper code paths work.
This validates the regression recently fixed which
broke reading in non-blocking mode

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAllow the iohelper path to be customized by test programs
Daniel P. Berrange [Fri, 10 May 2013 17:12:20 +0000 (18:12 +0100)]
Allow the iohelper path to be customized by test programs

Currently the fdstream function hardcodes the location
of the iohelper to LIBEXECDIR "/libvirt_iohelper". This
is not convenient when trying to write test cases which
use this code. Add a virFDStreamSetIOHelper method to
allow the test cases to point to the location of the
un-installed iohelper binary.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd a virGetLastErrorMessage() function
Daniel P. Berrange [Fri, 10 May 2013 17:09:44 +0000 (18:09 +0100)]
Add a virGetLastErrorMessage() function

Apps using libvirt will often have code like

   if (virXXXX() < 0) {
      virErrorPtr err = virGetLastError();
      fprintf(stderr, "Something failed: %s\n",
              err && err->message ? err->message :
              "unknown error");
      return -1;
   }

Checking for a NULL error object or message leads to very
verbose code. A virGetLastErrorMessage() helper from libvirt
can simplify this to

   if (virXXXX() < 0) {
      fprintf(stderr, "Something failed: %s\n",
              virGetLastErrorMessage());
      return -1;
   }

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix iohelper usage with streams opened for read
Daniel P. Berrange [Fri, 10 May 2013 13:45:05 +0000 (14:45 +0100)]
Fix iohelper usage with streams opened for read

In b2878ed860ceceec3cd6481424fed0b543b687cd we added the O_NOCTTY
flag when opening files in the stream code. Unfortunately a later
piece of code was comparing the flags == O_RDONLY, without masking
out the non-access mode flags. This broke the iohelper when used
with streams for read, since it caused us to attach the stream
output pipe to the stream input FD instead of output FD :-(

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoCope with missing swap cgroup controls
Daniel P. Berrange [Thu, 9 May 2013 12:53:39 +0000 (13:53 +0100)]
Cope with missing swap cgroup controls

It is possible to build a kernel without swap cgroup controls
present. This causes a fatal error when querying memory
parameters. Treat missing swap controls as meaning "unlimited".
The fatal error remains if the user tries to actually change
the limit.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoportability: fix virNetDevSetMAC and virNetDevExists on BSD
Roman Bogorodskiy [Fri, 3 May 2013 13:35:20 +0000 (17:35 +0400)]
portability: fix virNetDevSetMAC and virNetDevExists on BSD

- provide virNetDevSetMAC() implementation based on SIOCSIFLLADDR
  ioctl.
- adjust virNetDevExists() to check for ENXIO error because
  FreeBSD throws it when device doesn't exist

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoutil: move virFile* functions from virutil.c to virfile.c
Laine Stump [Thu, 9 May 2013 18:59:04 +0000 (14:59 -0400)]
util: move virFile* functions from virutil.c to virfile.c

These all existed before virfile.c was created, and for some reason
weren't moved.

This is mostly straightfoward, although the syntax rule prohibiting
write() had to be changed to have an exception for virfile.c instead
of virutil.c.

This movement pointed out that there is a function called
virBuildPath(), and another almost identical function called
virFileBuildPath(). They really should be a single function, which
I'll take care of as soon as I figure out what the arglist should look
like.

11 years agoutil: fix virFileOpenAs return value and resulting error logs
Laine Stump [Wed, 8 May 2013 19:02:14 +0000 (15:02 -0400)]
util: fix virFileOpenAs return value and resulting error logs

This resolves:

     https://bugzilla.redhat.com/show_bug.cgi?id=851411
     https://bugzilla.redhat.com/show_bug.cgi?id=955500

The first problem was that virFileOpenAs was returning fd (-1) in one
of the error cases rather than ret (-errno), so the caller thought
that the error was EPERM rather than ENOENT.

The second problem was that some log messages in the general purpose
qemuOpenFile() function would always say "Failed to create" even if
the caller hadn't included O_CREAT (i.e. they were trying to open an
existing file).

This fixes virFileOpenAs to jump down to the error return (which
returns ret instead of fd) in the previously mentioned incorrect
failure case of virFileOpenAs(), removes all error logging from
virFileOpenAs() (since the callers report it), and modifies
qemuOpenFile to appropriately use "open" or "create" in its log
messages.

NB: I seriously considered removing logging from all callers of
virFileOpenAs(), but there is at least one case where the caller
doesn't want virFileOpenAs() to log any errors, because it's just
going to try again (qemuOpenFile()). We can't simply make a silent
variation of virFileOpenAs() though, because qemuOpenFile() can't make
the decision about whether or not it wants to retry until after
virFileOpenAs() has already returned an error code.

Likewise, I also considered changing virFileOpenAs() to return -1 with
errno set on return, and may still do that, but only as a separate
patch, as it obscures the intent of this patch too much.

12 years agoBuild breaker - requires VIR_FROM_THIS
John Ferlan [Fri, 10 May 2013 12:52:43 +0000 (08:52 -0400)]
Build breaker - requires VIR_FROM_THIS

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/test/*
Michal Privoznik [Fri, 3 May 2013 12:49:30 +0000 (14:49 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/test/*

12 years agovirGetStorageVol: Don't ignore NULL pool name
Michal Privoznik [Fri, 10 May 2013 10:05:28 +0000 (12:05 +0200)]
virGetStorageVol: Don't ignore NULL pool name

The function takes pool name as argument. However,
it is not acceptable for it to be NULL. Hence, we
should check it and report error in case it is.

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/*
Michal Privoznik [Fri, 3 May 2013 12:52:48 +0000 (14:52 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/*

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in tests/*
Michal Privoznik [Fri, 3 May 2013 12:52:21 +0000 (14:52 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in tests/*

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/storage/*
Michal Privoznik [Fri, 3 May 2013 12:49:08 +0000 (14:49 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/storage/*

12 years agodom event example: Add error check to impl call
Jesse J. Cook [Thu, 9 May 2013 21:17:44 +0000 (16:17 -0500)]
dom event example: Add error check to impl call

Added error checking to virEventRegisterDefaultImpl call for consistency.

12 years agodom event example: init before register event impl
Jesse J. Cook [Thu, 9 May 2013 21:17:43 +0000 (16:17 -0500)]
dom event example: init before register event impl

In the domain-events example C code virEventRegisterDefaultImpl was being
called before virConnectOpen without first calling virInitialize. While this
code worked, it is incorrect. Adding a call to g_string_new prior to the call
to virEventRegisterDefaultImpl would cause the code to break. This fix will
help avoid unintentional misue of the API.

Relates to: Ret Hat Bugzilla - Bug 961155

12 years agoconf: Fix typo in error message in ABI stability check
Peter Krempa [Fri, 10 May 2013 07:54:56 +0000 (09:54 +0200)]
conf: Fix typo in error message in ABI stability check

s/vpu/vCPU/

12 years agotests: use portable shell code
Eric Blake [Thu, 9 May 2013 17:36:58 +0000 (11:36 -0600)]
tests: use portable shell code

'make check' fails since commit 470d5c46 on any system with dash
as /bin/sh, because '<<<' is a bash extension.  For example:

nwfilterschematest: 23: /home/eblake/libvirt/tests/schematestutils.sh: Syntax error: redirection unexpected

Also, there is no need to spawn a grep process when shell globbing
can do the same.

* tests/schematestutils.sh: Replace bashism and subprocess with a
faster and portable construct.

Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoReplace 'goto clean' with 'goto cleanup' in apparmor code
Daniel P. Berrange [Mon, 29 Apr 2013 17:38:21 +0000 (18:38 +0100)]
Replace 'goto clean' with 'goto cleanup' in apparmor code

Some of the apparmor code files did not follow the normal
goto label naming pratices

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoReplace list of driver source files with variables
Daniel P. Berrange [Mon, 29 Apr 2013 13:39:44 +0000 (14:39 +0100)]
Replace list of driver source files with variables

Update the DRIVER_SOURCE_FILES variable to reference the
other various XXX_SOURCES variables, instead of duplicating
the filename lists. This results in a bunch of extra files
being processed, but the test scripts can easily skip those

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix naming of methods in ESX storage backends to follow public APIs
Daniel P. Berrange [Mon, 29 Apr 2013 13:37:58 +0000 (14:37 +0100)]
Fix naming of methods in ESX storage backends to follow public APIs

The previous update of method naming missed the ESX storage
backend files. Update them is that the driver impl methods
follow the naming of the public API but with s/vir/esx/

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSkip virNWFilterTechDriver when validating API naming
Daniel P. Berrange [Mon, 29 Apr 2013 13:39:04 +0000 (14:39 +0100)]
Skip virNWFilterTechDriver when validating API naming

The virNWFilterTechDriver struct is an internal only driver
API with no public API equivalent. It should be skipped by
the 'check-driverimpls' test case

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoReplace 'goto cleanup' with 'goto error' in udev interface driver
Daniel P. Berrange [Thu, 9 May 2013 16:09:12 +0000 (17:09 +0100)]
Replace 'goto cleanup' with 'goto error' in udev interface driver

Some methods in the udev interface driver used 'cleanup' as the
label for separate error codepaths. Change these to use 'error'
as required by coding standards

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoReplace 'goto err' with 'goto cleanup' in udev interface driver
Daniel P. Berrange [Mon, 29 Apr 2013 17:37:48 +0000 (18:37 +0100)]
Replace 'goto err' with 'goto cleanup' in udev interface driver

The udev interface driver did not follow standard naming
convention for goto labels.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoDisable some URI tests on older libxml2
Daniel P. Berrange [Wed, 8 May 2013 15:11:09 +0000 (16:11 +0100)]
Disable some URI tests on older libxml2

Older versions of libxml2 could not correctly parse certain
URIs. This causes test failures. There's nothing libvirt can
do about this, so disable the problem tests on old libxml2
versions

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix build of python bindings on Python 2.4
Daniel P. Berrange [Wed, 8 May 2013 14:42:03 +0000 (15:42 +0100)]
Fix build of python bindings on Python 2.4

The PyDict_Next method on Python <= 2.4 used 'int' instead
of "Py_ssize_t" for the 'pos' parameter

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agobuild: fix build with old polkit0
Jim Fehlig [Thu, 9 May 2013 15:46:29 +0000 (09:46 -0600)]
build: fix build with old polkit0

Commit 979e9c56 missed one case of providing the timestamp
parameter to virNetServerClientGetUNIXIdentity() when WITH_POLKIT0
is defined.

12 years agoconf: don't crash on a tpm device with no backends
Ján Tomko [Thu, 9 May 2013 10:33:11 +0000 (12:33 +0200)]
conf: don't crash on a tpm device with no backends

Print an error instead of crashing when a TPM device without
a backend is specified.

Add a test for tpm device with no backend, which should fail
with a parse error.

https://bugzilla.redhat.com/show_bug.cgi?id=961252

12 years agotests: files named '.*-invalid.xml' should fail validation
Ján Tomko [Thu, 9 May 2013 11:43:32 +0000 (13:43 +0200)]
tests: files named '.*-invalid.xml' should fail validation

Currently, using an invalid XML in tests fails, because
the schema test expects all of them to be valid.

Treat files with -invalid.xml suffix as invalid and expect
them to fail validation.

12 years agodon't mention disk controllers in generic controller errors
Ján Tomko [Thu, 9 May 2013 09:39:21 +0000 (11:39 +0200)]
don't mention disk controllers in generic controller errors

The controller element supports non-disk controller types too.

https://bugzilla.redhat.com/show_bug.cgi?id=960958

12 years agoiscsi: don't leak portal string when starting a pool
Ján Tomko [Mon, 6 May 2013 12:36:23 +0000 (14:36 +0200)]
iscsi: don't leak portal string when starting a pool

12 years agoSimplify the Xen domain stats/peek / node memory driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:55:18 +0000 (17:55 +0100)]
Simplify the Xen domain stats/peek / node memory driver methods

Make the Xen domain stats / peek and node memory driver
methods unconditionally call the sub-drivers which are
guaranteed to be open.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain autostart driver method
Daniel P. Berrange [Thu, 2 May 2013 13:36:45 +0000 (14:36 +0100)]
Simplify the Xen domain autostart driver method

Unconditionally call into the XenD or XM drivers for autostart
handling, since they are guaranteed to be open

12 years agoSimplify the Xen domain scheduler parameter driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:52:19 +0000 (17:52 +0100)]
Simplify the Xen domain scheduler parameter driver methods

Make the Xen domain scheduler parameter methods directly
call into XenD or Xen hypervisor drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain attach/dettach driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:43:07 +0000 (17:43 +0100)]
Simplify the Xen domain attach/dettach driver methods

Make the domain attach/dettach driver methods directly call
into either the XenD or XM drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain define/undefine driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:39:29 +0000 (17:39 +0100)]
Simplify the Xen domain define/undefine driver methods

Make the domain define/undefine driver methods directly call
into either the XenD or XM drivers

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain start driver method
Daniel P. Berrange [Tue, 30 Apr 2013 16:33:48 +0000 (17:33 +0100)]
Simplify the Xen domain start driver method

Directly call either the XenD or XM driver when starting
a persistent domain

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen driver define domain driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:31:40 +0000 (17:31 +0100)]
Simplify the Xen driver define domain driver methods

Directly call either XenD or the XM driver for handling
domain define operations.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain migration driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:27:59 +0000 (17:27 +0100)]
Simplify the Xen domain migration driver methods

All the migration code is done by the XenD subdriver which
can be assumed to always be present

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain get XML driver method
Daniel P. Berrange [Tue, 30 Apr 2013 16:26:30 +0000 (17:26 +0100)]
Simplify the Xen domain get XML driver method

The xenUnifiedDomainGetXMLDesc driver can assume that
the XM and XenD drivers are always present

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain VCPU driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 16:25:27 +0000 (17:25 +0100)]
Simplify the Xen domain VCPU driver methods

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain save/restore driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 15:44:21 +0000 (16:44 +0100)]
Simplify the Xen domain save/restore driver methods

Unconditionally call the XenD APIs for save/restore, since that
driver will always be open.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain get info/state driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 15:42:29 +0000 (16:42 +0100)]
Simplify the Xen domain get info/state driver methods

Make the xenUnifiedDomainGetInfo and xenUnifiedDomainGetState drivers
call the correct sub-driver APIs directly.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain get/set (max) memory driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 15:31:33 +0000 (16:31 +0100)]
Simplify the Xen domain get/set (max) memory driver methods

Simplify the Xen memory limit driver methods to directly call
the most appropriate sub-driver

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove Xen get hostname driver method
Daniel P. Berrange [Tue, 30 Apr 2013 15:15:28 +0000 (16:15 +0100)]
Remove Xen get hostname driver method

The xenGetHostname entry point in the xenUnifiedDriver table
was unused.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain get OS type driver method
Daniel P. Berrange [Tue, 30 Apr 2013 15:04:36 +0000 (16:04 +0100)]
Simplify the Xen domain get OS type driver method

Make xenUnifiedDomainGetOSType directly call either the
xenHypervisorDomainGetOSType or xenDaemonDomainGetOSType
method depending on whether the domain is active or not.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain destroy driver method
Daniel P. Berrange [Tue, 30 Apr 2013 14:41:52 +0000 (15:41 +0100)]
Simplify the Xen domain destroy driver method

Unconditionally call the xenDaemonDomainDestroyFlags API
since the XenD driver is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain shutdown/reboot driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 14:38:32 +0000 (15:38 +0100)]
Simplify the Xen domain shutdown/reboot driver methods

Make the xenUnifiedDomainShutdownFlags and xenUnifiedDomainReboot
driver methods unconditionally call the XenD APIs for shutdown
and reboot. Delete the unreachable impls in the XenStore driver.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain suspend/resume driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 14:33:51 +0000 (15:33 +0100)]
Simplify the Xen domain suspend/resume driver methods

Update xenUnifiedDomainSuspend and xenUnifiedDomainResume to
unconditionally invoke the XenD APIs for suspend/resume. Delete
the impls in the hypervisor driver which was unreachable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain is persistent driver method
Daniel P. Berrange [Tue, 30 Apr 2013 14:12:47 +0000 (15:12 +0100)]
Simplify the Xen domain is persistent driver method

Unconditionally call xenDaemonLookupByUUID, since the XenD
driver must always be present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain lookup driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 14:05:10 +0000 (15:05 +0100)]
Simplify the Xen domain lookup driver methods

Unconditionally invoke the xenHypervisorLookupDomainByID,
xenHypervisorLookupDomainByUUID or xenDaemonLookupByName
for looking up domains. Fallback to xenXMDomainLookupByUUID
and xenXMDomainLookupByName for legacy XenD without inactive
domain support

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen domain create driver method
Daniel P. Berrange [Tue, 30 Apr 2013 14:01:22 +0000 (15:01 +0100)]
Simplify the Xen domain create driver method

Unconditionally call xenDaemonCreateXML in the
xenUnifiedDomainCreateXML driver, since the XenD
driver is always present.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen count/list domains driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 14:00:13 +0000 (15:00 +0100)]
Simplify the Xen count/list domains driver methods

The XenStore driver is mandatory, so it can be used unconditonally
for the xenUnifiedConnectListDomains & xenUnifiedConnectNumOfDomains
drivers. Delete the unused XenD and Hypervisor driver code for
listing / counting domains

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen get max vcpus / node get info driver methods
Daniel P. Berrange [Tue, 30 Apr 2013 13:57:03 +0000 (14:57 +0100)]
Simplify the Xen get max vcpus / node get info driver methods

Unconditionally call into xenHypervisorGetMaxVcpus and
xenDaemonNodeGetInfo respectively, since those drivers
are both mandatory

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen get version driver method
Daniel P. Berrange [Tue, 30 Apr 2013 13:53:50 +0000 (14:53 +0100)]
Simplify the Xen get version driver method

The hypervisor driver is mandatory, so the the call to
xenHypervisorGetVersion must always succeed. Thus there
is no need to ever run xenDaemonGetVersion

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify the Xen get type driver method
Daniel P. Berrange [Tue, 30 Apr 2013 13:51:40 +0000 (14:51 +0100)]
Simplify the Xen get type driver method

There is no point iterating over sub-drivers since the user
would not have a virConnectPtr instance at all if opening
the drivers failed. Just return 'Xen' immediately.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSimplify opening of Xen drivers
Daniel P. Berrange [Tue, 30 Apr 2013 13:41:48 +0000 (14:41 +0100)]
Simplify opening of Xen drivers

Since the Xen driver was changed to only execute inside libvirtd,
there is no scenario in which it will be opened from a non-privileged
context. Thus all the code dealing with opening the sub-drivers can
be simplified to assume that they are always privileged.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove pointless GET_PRIVATE macro from Xen driver
Daniel P. Berrange [Tue, 30 Apr 2013 12:32:48 +0000 (13:32 +0100)]
Remove pointless GET_PRIVATE macro from Xen driver

The Xen driver uses a macro GET_PRIVATE as a supposed shorthand
for 'xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) (conn)->privateData'.
It does not in fact save any lines of code, and obscures what is
happening. Remove it, since it adds no value.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove VIR_CONNECT_RO checks from xen drivers
Daniel P. Berrange [Thu, 2 May 2013 13:13:34 +0000 (14:13 +0100)]
Remove VIR_CONNECT_RO checks from xen drivers

Some of the Xen sub-drivers have checks against the
VIR_CONNECT_RO flag. This is not required, since such
checks are done at the top level before the driver
methods are invoked

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRemove xen driver checks for priv->handle < 0
Daniel P. Berrange [Tue, 30 Apr 2013 12:16:06 +0000 (13:16 +0100)]
Remove xen driver checks for priv->handle < 0

The Xen hypervisor driver checks for 'priv->handle < 0' and
returns -1, but without raising any error. Fortunately this
code will never be executed, since the main Xen driver always
checks 'priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET]' prior
to invoking any hypervisor API. Just remove the redundant
checks for priv->handle

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/vmx/*
Michal Privoznik [Fri, 3 May 2013 12:51:02 +0000 (14:51 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/vmx/*

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/vmware/*
Michal Privoznik [Fri, 3 May 2013 12:50:46 +0000 (14:50 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/vmware/*

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/uml/*
Michal Privoznik [Fri, 3 May 2013 12:49:48 +0000 (14:49 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/uml/*

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/secret/*
Michal Privoznik [Fri, 3 May 2013 12:48:16 +0000 (14:48 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/secret/*

12 years agoAdapt to VIR_STRDUP and VIR_STRNDUP in src/phyp/*
Michal Privoznik [Fri, 3 May 2013 12:46:23 +0000 (14:46 +0200)]
Adapt to VIR_STRDUP and VIR_STRNDUP in src/phyp/*