]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agovirnetdev allow to set peer address
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:02 +0000 (21:00 +0000)]
virnetdev allow to set peer address

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
9 years agolibxl: libxl_domain_create_restore has an extra argument
Wei Liu [Tue, 5 Apr 2016 14:20:12 +0000 (15:20 +0100)]
libxl: libxl_domain_create_restore has an extra argument

In the latest libxenlight code, libxl_domain_create_restore accepts a
new argument. Update libvirt's libxl driver for that. Use the macro
provided by libxenlight to detect which version should be used.

The new parameter (send_back_fd) is set to -1 because libvirt provides
no such fd.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Message-id: 1459866012-27081-1-git-send-email-wei.liu2@citrix.com

9 years agoqemu: Explicitly check for gnutls_rnd()
Andrea Bolognani [Thu, 7 Apr 2016 11:48:48 +0000 (13:48 +0200)]
qemu: Explicitly check for gnutls_rnd()

Our use of gnutls_rnd(), introduced with commit ad7520e8, is
conditional to the availability of the <gnutls/crypto.h> header
file.

Such check, however, turns out not to be strict enough, as there
are some versions of GnuTLS (eg. 2.8.5 from CentOS 6) that provide
the header file, but not the function itself, which was introduced
only in GnuTLS 2.12.0.

Introduce an explicit check for the function.

9 years agoconfigure: Always use old_CFLAGS and old_LIBS
Andrea Bolognani [Thu, 7 Apr 2016 13:04:42 +0000 (15:04 +0200)]
configure: Always use old_CFLAGS and old_LIBS

The variables used for storing CFLAGS and LIBS before temporarily
modifying them was consistent when it comes to the name, but not
when it comes to the case.

Make sure names are completely consistent.

9 years agoconfigure: Restore CFLAGS properly after GnuTLS checks
Andrea Bolognani [Thu, 7 Apr 2016 13:00:42 +0000 (15:00 +0200)]
configure: Restore CFLAGS properly after GnuTLS checks

The previous value of CFLAGS was saved as old_cflags but later
restored from old_CFLAGS, which is clearly not correct.

Restore CFLAGS from the right variable.

9 years agohost-validate: Improve CPU flags processing
Andrea Bolognani [Tue, 29 Mar 2016 14:38:28 +0000 (16:38 +0200)]
host-validate: Improve CPU flags processing

Instead of relying on substring search, tokenize the input
and process each CPU flag separately. This ensures CPU flag
detection will continue to work correctly even if we start
looking for CPU flags whose name might appear as part of
other CPU flags' names.

The result of processing is stored in a virBitmap, which
means we don't have to parse /proc/cpuinfo in its entirety
for each single CPU flag we want to check.

Moreover, use of the newly-introduced virHostValidateCPUFlag
enumeration ensures we don't go looking for random CPU flags
which might actually be simple typos.

9 years agovz: support boot order in domain xml dump
Nikolay Shirokovskiy [Tue, 22 Mar 2016 13:56:38 +0000 (16:56 +0300)]
vz: support boot order in domain xml dump

As usual we try to deal correctly with vz domains that were
created by other means and thus can have all range of SDK domain
parameters. If vz domain boot order can't be represented
in libvirt os boot section let's give warning and make os boot section
represent SDK to some extent.

1. Os boot section supports up to 4 boot devices. Here we just
cut SDK boot order up to this limit. Not too bad.

2. If there is a floppy in boot order let's just skip it.
Anyway we don't show it in the xml. Not too bad too.

3. SDK boot order with unsupported disks order. Say we have "hdb, hda" in
SDK. We can not present this thru os boot order. Well let's just
give warning but leave double <boot dev='hd'/> in xml. It's
kind of misleading but we warn you!

SDK boot order have an extra parameters 'inUse' and 'sequenceIndex'
which makes our task more complicated. In realitly however 'inUse'
is always on and 'sequenceIndex' is not less than 'boot position index'
which simplifies out task back again! To be on a safe side let's explicitly
check for this conditions!

We have another exercise here. We want to check for unrepresentable
condition 3 (see above). The tricky part is that in contrast to
domains defined thru this driver 3-rd party defined domains can
have device ordering different from default. Thus we need
some id to check that N-th boot disk of os boot section is same as
N-th boot disk of SDK boot. This is what prlsdkBootOrderCheck
for. It uses disks sources paths as id for disks and iface names
for network devices.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: fix disk order on load domain
Nikolay Shirokovskiy [Tue, 22 Mar 2016 13:56:37 +0000 (16:56 +0300)]
vz: fix disk order on load domain

We want to report boot order in dumpxml for vz domains.
Thus we want disks devices to be sorted in output compatible with boot
ordering specification. So let's just use virDomainDiskInsert
which makes appropriate sorting.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: support boot order specification on define domain
Nikolay Shirokovskiy [Tue, 22 Mar 2016 13:56:36 +0000 (16:56 +0300)]
vz: support boot order specification on define domain

The patch makes some refactoring of the existing code. Current boot order spec code
makes very simple thing in somewhat obscure way. In case of VMs
it sets the first hdd as the only bootable device. In case of CTs it
doesn't touch the boot order at all if one of the filesystems is mounted to root.
Otherwise like in case of VMs it sets the first hdd as the only bootable
device and additionally sets this device mount point to root. Refactored
code makes all this explicit.

The actual boot order support is simple. Common libvirt domain xml parsing
code makes the exact ordering of disks devices as described in docs
for boot ordering (disks are sorted by bus order first, device target
second. Bus order is the order of disk buses appearence in original
xml. Device targets order is alphabetical). We add devices in the
same order and SDK designates device indexes sequentially for each
device type. Thus device index is equal to its boot index. For
example N-th cdrom in boot specification refers to sdk cdrom with
it's device index N.

If there is no boot spec in xml the parsing code will add <boot dev='hdd'>
for HVMs automatically and we backward compatibly set fist hdd as
bootable.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agoqemu: perf: Fix crash/memory corruption on failed VM start
Peter Krempa [Thu, 7 Apr 2016 10:50:15 +0000 (12:50 +0200)]
qemu: perf: Fix crash/memory corruption on failed VM start

The new perf code didn't bother to clear a pointer in 'priv' causing a
double free or other memory corruption goodness if a VM failed to start.

Clear the pointer after freeing the memory.

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

9 years agoqemu: alias: Fix calculation of memory device aliases
Peter Krempa [Wed, 6 Apr 2016 15:32:12 +0000 (17:32 +0200)]
qemu: alias: Fix calculation of memory device aliases

For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

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

9 years agoqemu: alias: Fix calculation of RNG device aliases
Peter Krempa [Wed, 6 Apr 2016 15:32:12 +0000 (17:32 +0200)]
qemu: alias: Fix calculation of RNG device aliases

For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

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

9 years agosecret: Introduce virSecretGetSecretString
John Ferlan [Mon, 4 Apr 2016 17:31:29 +0000 (13:31 -0400)]
secret: Introduce virSecretGetSecretString

Commit id 'fb2bd208' essentially copied the qemuGetSecretString
creating an libxlGetSecretString.  Rather than have multiple copies
of the same code, create src/secret/secret_util.{c,h} files and
place the common function in there.

Modify the the build in order to build the module as a library
which is then pulled in by both the qemu and libxl drivers for
usage from both qemu_command.c and libxl_conf.c

9 years agoqemu: Introduce qemuBuildMasterKeyCommandLine
John Ferlan [Tue, 29 Mar 2016 22:23:02 +0000 (18:23 -0400)]
qemu: Introduce qemuBuildMasterKeyCommandLine

If the -object secret capability exists, then get the path to the
masterKey file and provide that to qemu. Checking for the existence
of the file before passing to qemu could be done, but causes issues
in mock test environment.

Since the qemuDomainObjPrivate is not available when building the
command line, the qemuBuildHasMasterKey API will have to suffice
as the primary arbiter for whether the capability exists in order
to find/return the path to the master key for usage.

Created the qemuDomainGetMasterKeyAlias API which will be used by
later patches to define the 'keyid' (eg, masterKey) to be used by
other secrets to provide the id to qemu for the master key.

9 years agoqemu: Create domain master key
John Ferlan [Tue, 29 Mar 2016 22:22:46 +0000 (18:22 -0400)]
qemu: Create domain master key

Add a masterKey and masterKeyLen to _qemuDomainObjPrivate to store a
random domain master key and its length in order to support the ability
to encrypt/decrypt sensitive data shared between libvirt and qemu. The
key will be base64 encoded and written to a file to be used by the
command line building code to share with qemu.

New API's from this patch:

  qemuDomainGetMasterKeyFilePath:
    Return a path to where the key is located

  qemuDomainWriteMasterKeyFile: (private)
    Open (create/trunc) the masterKey path and write the masterKey

  qemuDomainMasterKeyReadFile:
    Using the master key path, open/read the file, and store the
    masterKey and masterKeyLen. Expected use only from qemuProcessReconnect

  qemuDomainGenerateRandomKey: (private)
    Generate a random key using available algorithms

    The key is generated either from the gnutls_rnd function if it
    exists or a less cryptographically strong mechanism using
    virGenerateRandomBytes

   qemuDomainMasterKeyRemove:
    Remove traces of the master key, remove the *KeyFilePath

  qemuDomainMasterKeyCreate:
    Generate the domain master key and save the key in the location
    returned by qemuDomainGetMasterKeyFilePath.

    This API will first ensure the QEMU_CAPS_OBJECT_SECRET is set
    in the capabilities. If not, then there's no need to generate
    the secret or file.

The creation of the key will be attempted from qemuProcessPrepareHost
once the libDir directory structure exists.

The removal of the key will handled from qemuProcessStop just prior
to deleting the libDir tree.

Since the key will not be written out to the domain object XML file,
the qemuProcessReconnect will read the saved file and restore the
masterKey and masterKeyLen.

9 years agoutil: Introduce virRandomBytes
John Ferlan [Tue, 29 Mar 2016 22:15:33 +0000 (18:15 -0400)]
util: Introduce virRandomBytes

Using the existing virUUIDGenerateRandomBytes, move API to virrandom.c
rename it to virRandomBytes and add it to libvirt_private.syms.

This will be used as a fallback for generating a domain master key.

9 years agoqemu: Add capability bit for qemu secret object
John Ferlan [Mon, 21 Mar 2016 15:49:12 +0000 (11:49 -0400)]
qemu: Add capability bit for qemu secret object

Add a capability bit for the qemu secret object.

Adjust the 2.6.0-1 caps/replies to add the secret object. For the
.replies it's take from the '{"execute":"qom-list-types"}' output.

9 years agoqemu: Tear down the cgroup before reattach device to host
John Ferlan [Mon, 28 Mar 2016 11:40:57 +0000 (07:40 -0400)]
qemu: Tear down the cgroup before reattach device to host

When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
qemuTeardownHostdevCgroup to prior to reattaching the device to
the host.

9 years agoqemu: Restore label before reattach device to host
John Ferlan [Mon, 28 Mar 2016 11:34:03 +0000 (07:34 -0400)]
qemu: Restore label before reattach device to host

When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
virSecurityManagerRestoreHostdevLabel to prior to reattaching the
device to the host.

9 years agoLink libvirt_xenconfig instead of libvirt against libxl
Guido Günther [Thu, 31 Mar 2016 12:57:24 +0000 (14:57 +0200)]
Link libvirt_xenconfig instead of libvirt against libxl

to avoid the test failure

 7) Test driver "xen"  ... 2016-03-31 12:53:26.950+0000: 22430: debug : virDriverLoadModule:54 : Module load xen
 2016-03-31 12:53:26.950+0000: 22430: error : virDriverLoadModule:73 : failed to load module /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so: undefined symbol: xlu_cfg_destroy
FAILED

9 years agovirt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var
Ján Tomko [Wed, 6 Apr 2016 12:57:21 +0000 (14:57 +0200)]
virt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var

There is a LIBVIRT_ADMIN_DEFAULT_URI environment variable
which is honored by virAdmConnectOpen and documented
in the virt-admin man page.

LIBVIRT_DEFAULT_ADMIN_URI is undocumented and this is its
only occurrence.

9 years agolibvirt-admin: do not crash on URI without a scheme
Ján Tomko [Wed, 6 Apr 2016 08:43:39 +0000 (10:43 +0200)]
libvirt-admin: do not crash on URI without a scheme

9 years agotools: remove unnecessary defaultConn variable
Ján Tomko [Wed, 6 Apr 2016 08:42:02 +0000 (10:42 +0200)]
tools: remove unnecessary defaultConn variable

vshStrdup returns NULL without exiting on NULL input.

9 years agovirsh: read default connection uri from env later
Ján Tomko [Wed, 6 Apr 2016 08:08:55 +0000 (10:08 +0200)]
virsh: read default connection uri from env later

Postpone filling out the default connection in ctl->connname
after calling virshInit.

This allows printing help without a connection to the daemon.

9 years agospec: Include KVM support on RHEL 7 ppc64 and newer
Andrea Bolognani [Thu, 17 Mar 2016 10:00:54 +0000 (11:00 +0100)]
spec: Include KVM support on RHEL 7 ppc64 and newer

9 years agoconf: store bootindex as unsigned int
Peter Krempa [Tue, 29 Mar 2016 12:31:37 +0000 (14:31 +0200)]
conf: store bootindex as unsigned int

The value is never negative thus there's no need to store it in a signed
type.

9 years agoconf: Pass the whole device info struct to virDomainDeviceBootParseXML
Peter Krempa [Tue, 29 Mar 2016 10:01:39 +0000 (12:01 +0200)]
conf: Pass the whole device info struct to virDomainDeviceBootParseXML

No need to extract the single element.

9 years agoPost-release version bump to 1.3.4
Peter Krempa [Wed, 6 Apr 2016 07:18:16 +0000 (09:18 +0200)]
Post-release version bump to 1.3.4

9 years agoRelease of libvirt-1.3.3
Daniel Veillard [Wed, 6 Apr 2016 07:18:46 +0000 (15:18 +0800)]
Release of libvirt-1.3.3
- docs/news.html.in libvirt.spec.in: update for release
- po/*.po*: regenerated

9 years agodocs: fix logfile paragraph
Boris Fiuczynski [Tue, 5 Apr 2016 12:44:43 +0000 (14:44 +0200)]
docs: fix logfile paragraph

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agonetwork: Remove extraneous ATTRIBUTE_NONNULL
John Ferlan [Tue, 5 Apr 2016 09:43:47 +0000 (05:43 -0400)]
network: Remove extraneous ATTRIBUTE_NONNULL

Commit id '3992ff14' added the prototype for networkGetActualType
with 1 parameter, but added 2 ATTRIBUTE_NONNULL's (assume from a
cut-n-paste), just remove (2).

9 years agoqemu: Fix mis-merge of qemuBuildRedirdevCommandLine
John Ferlan [Mon, 4 Apr 2016 19:27:58 +0000 (15:27 -0400)]
qemu: Fix mis-merge of qemuBuildRedirdevCommandLine

Commit id '59e7ef3c' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agoqemu: Fix mis-merge of qemuBuildConsoleCommandLine
John Ferlan [Mon, 4 Apr 2016 19:26:43 +0000 (15:26 -0400)]
qemu: Fix mis-merge of qemuBuildConsoleCommandLine

Commit id 'e6944a52' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agoqemu: Fix mis-merge of qemuBuildChannelsCommandLine
John Ferlan [Mon, 4 Apr 2016 19:24:28 +0000 (15:24 -0400)]
qemu: Fix mis-merge of qemuBuildChannelsCommandLine

Commit id '3cdcc910' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agoqemu: Fix mis-merge of qemuBuildParallelsCommandLine
John Ferlan [Mon, 4 Apr 2016 19:23:07 +0000 (15:23 -0400)]
qemu: Fix mis-merge of qemuBuildParallelsCommandLine

Commit id '0e1e7ade' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agoqemu: Fix mis-merge of qemuBuildSerialCommandLine
John Ferlan [Mon, 4 Apr 2016 19:21:57 +0000 (15:21 -0400)]
qemu: Fix mis-merge of qemuBuildSerialCommandLine

Commit id '5ab8640' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agoqemu: Fix mis-merge of qemuBuildSmartcardCommandLine
John Ferlan [Mon, 4 Apr 2016 19:19:57 +0000 (15:19 -0400)]
qemu: Fix mis-merge of qemuBuildSmartcardCommandLine

Commit id '858bafeb' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agonodedev: Fix parsing of generated XMLs
Martin Kletzander [Sun, 3 Apr 2016 17:55:54 +0000 (19:55 +0200)]
nodedev: Fix parsing of generated XMLs

Commit d77ffb6876 added not only reporting of the PCI header type, but
also parsing of that information.  However, because there was no parsing
done for the other sub-PCI capabilities, if there was any other
capability then a valid header type name (like phys_function or
virt_functions) the parsing would fail.  This prevented passing node
device XMLs that we generated into our own functions when dealing with,
e.g. with SRIOV cards.

Instead of reworking the whole parsing, just fix this one occurence and
remove a test for it for the time being.  Future patches will deal with
the rest.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: fix alias name for <interface type='hostdev'>
Laine Stump [Fri, 1 Apr 2016 17:18:57 +0000 (13:18 -0400)]
qemu: fix alias name for <interface type='hostdev'>

Starting with commit f8e712fe, if you start a domain that has an
<interface type='hostdev' (or that has <interface type='network'>
where the network is a pool of devices for hostdev assignment), when
you later try to add *another* interface (of any kind) with hotplug,
the function qemuAssignDeviceNetAlias() fails as soon as it sees a
"hostdevN" alias in the list of interfaces), causing the attach to
fail.

This is because (starting with f8e712fe) the device alias names are
assigned during the new function qemuProcessPrepareDomain(), which is
called *before* networkAllocateActualDevice() (which is called from
qemuProcessPrepareHost(), which is called from
qemuProcessLaunch()). Prior to that commit,
networkAllocateActualDevice() was called first.

The problem with this is that the alias for interfaces that are really
a hostdev (<interface type='hostdev'>) is of the form "hostdevN" (just
like other hostdevs), while other interfaces are "netN". But if you
don't know that the interface is going to be a hostdev at the time you
assign the alias name, you can't name it differently. (As far as I've
seen so far, the change in name by itself wouldn't have been a problem
(other than just an outwardly noticeable change in behavior) except
for the abovementioned failure to attach/detach new interfaces.

Rather than take the chance that there may be other not-yet-revealed
problems associated with changing the alias name, this patch changes
the way that aliases are assigned to restore the old behavior.

Old: In the past, assigning an alias to an interface was skipped if it
was seen that the interface was type='hostdev' - we knew that the
hostdev part of the interface was also in the list of hostdevs (that's
part of what happens in networkAllocateActualDevice()) and it would be
assigned when all the other hostdev aliases were assigned.

New: When assigning an alias to an interface, we haven't yet called
networkAllocateActualDevice() to construct the hostdev part of the
interface, so we can't just wait for the loop that creates aliases for
all the hostdevs (there's nothing on that list for this device
yet!). Instead we handle it immediately in the loop creating interface
aliases, by calling the new function networkGetActualType() to
determine if it is going to be hostdev, and if so calling
qemuAssignDeviceHostdevAlias() instead.

Some adjustments have to be made to both
qemuAssignDeviceHostdevAlias() and to qemuAssignDeviceNetAlias() to
accommodate this. In both of them, an error return from
qemuDomainDeviceAliasIndex() is no longer considered an error; instead
it's just ignored (because it almost certainly means that the alias
string for the device was "net" when we expected "hostdev" or vice
versa). in qemuAssignDeviceHostdevAlias() we have to look at all
interface aliases for hostdevN in addition to looking at all hostdev
aliases (this wasn't necessary in the past, because both the interface
entry and the hostdev entry for the device already pointed at the
device info; no longer the case since the hostdev entry hasn't yet
been setup).

Fortunately the buggy behavior hasn't yet been in any official release
of libvirt.

9 years agoqemu: change args to qemuAssignDeviceHostdevAlias()
Laine Stump [Fri, 1 Apr 2016 14:40:23 +0000 (10:40 -0400)]
qemu: change args to qemuAssignDeviceHostdevAlias()

In certain cases, we need to assign a hostdevN-style alias in a case
when we don't have a virDomainHostdevDefPtr (instead we have a
virDomainNetDefPtr). Since qemuAssignDeviceHostdevAlias() doesn't use
anything in the virDomainHostdevDef except the alias string itself
anyway, this patch just changes the arguments to pass a pointer to the
alias pointer instead.

9 years agonetwork: new function networkGetActualType
Laine Stump [Fri, 1 Apr 2016 13:45:51 +0000 (09:45 -0400)]
network: new function networkGetActualType

There are times when it's necessary to learn the actual type of a
network connection before any resources have been allocated
(e.g. during qemuProcessPrepareDomain()), but in the past it was
necessary to call networkAllocateActualDevice() in order to have the
actual type filled in.

This new function returns the type of network that *will be* setup
once it actually happens, but without making any changes on the host.

9 years agoqemu: Clear generated private paths
Martin Kletzander [Sun, 3 Apr 2016 19:51:29 +0000 (21:51 +0200)]
qemu: Clear generated private paths

The paths have the domain ID in them.  Without cleaning them, they would
contain the same ID even after multiple restarts.  That could cause
various problems, e.g. with access.

Add function qemuDomainClearPrivatePaths() for this as a counterpart of
qemuDomainSetPrivatePaths().

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Simplify calls to qemuDomainSetPrivatePaths
Martin Kletzander [Sun, 3 Apr 2016 19:59:46 +0000 (21:59 +0200)]
qemu: Simplify calls to qemuDomainSetPrivatePaths

Since commit 9dca74ee6f54, the function can take driver and a vm, no
need to overcomplicate.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoapparmor: QEMU monitor socket moved
Guido Günther [Sat, 2 Apr 2016 10:49:28 +0000 (12:49 +0200)]
apparmor: QEMU monitor socket moved

The directory name changed in a89f05ba8df095875f5ec8a9065a585af63a010b.

This unbreaks launching QEMU/KVM VMs with apparmor enabled. It also adds
the directory for the qemu guest-agent socket which is not known when
parsing the domain XML.

9 years agoRevert "hostdev: Use actual device when reattaching"
Andrea Bolognani [Fri, 1 Apr 2016 12:51:29 +0000 (14:51 +0200)]
Revert "hostdev: Use actual device when reattaching"

This reverts commit ee4cfb56436b50345b072c706b87aff82e06d760.

Since we're still not persisting our bookkeeping lists across
daemon restarts, we might have lost some information
virPCIDeviceReattach() relies on, for example whether the
device needs to be unbound from the stub driver.

As a result, if the daemon has been restarted in the meantime,
the device might end up remaining bound to the stub driver even
after 'virsh nodedev-reattach' or similar has been called, with
no way of giving it back to the host short of messing with
sysfs behind libvirt's back.

Revert back to the previous behavior of always trying to bind
the device to the host driver, regardless of its status when it
was detached, until persistent bookkeeping lists have been
implemented.

9 years agodocs: Remove useless p:first-line CSS rule
Andrea Bolognani [Fri, 1 Apr 2016 09:31:11 +0000 (11:31 +0200)]
docs: Remove useless p:first-line CSS rule

According to MDN[1], 'margin-left' and similar CSS properties,
including 'margin-right', cannot be applied to the '::first-line'
pseudo-element, so this rule will never have any effect and can
be safely removed.

[1] https://developer.mozilla.org/en/docs/Web/CSS/::first-line

9 years agodocs: Remove unused #sponsor CSS rule
Andrea Bolognani [Fri, 1 Apr 2016 08:59:36 +0000 (10:59 +0200)]
docs: Remove unused #sponsor CSS rule

Commit e14c5069c512 dropped the only user of the 'sponsor'
CSS id, so we can drop it from the stylesheet as well.

9 years agoPass the correct cpu count when calling virDomainGetCPUStats.
Nitesh Konkar [Fri, 1 Apr 2016 06:05:04 +0000 (02:05 -0400)]
Pass the correct cpu count when calling virDomainGetCPUStats.

When using the --start option, the show_count should not be set to
max_id as the --start <cpu> means we dont need those many initial cpu
stats. Hence, show_count should be adjusted accordingly.

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

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agomigration: convert speed from MiB/sec to bytes/sec in drive-mirror jobs
Rudy Zhang [Fri, 1 Apr 2016 02:16:53 +0000 (10:16 +0800)]
migration: convert speed from MiB/sec to bytes/sec in drive-mirror jobs

Commit 08cc14f moved the conversion of MiB/s to B/s out of the
qemuMonitor APIs, but forgot to adjust the qemuMigrationDriveMirror
caller.

This patch will convert the migrate_speed value from MiB/s to its
mirror_speed equivalent in bytes/s.

Signed-off-by: Rudy Zhang <rudyflyzhang@gmail.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoqemu: perf: Tweak flags before using them
Peter Krempa [Thu, 31 Mar 2016 14:45:14 +0000 (16:45 +0200)]
qemu: perf: Tweak flags before using them

@flags have a valid modification impact only after calling
virDomainObjUpdateModificationImpact. virDomainObjGetOneDef calls it but
doesn't update them in the caller.

9 years agolibxl: fix net device detach
Jim Fehlig [Wed, 30 Mar 2016 21:12:35 +0000 (15:12 -0600)]
libxl: fix net device detach

Chunyan sent a nice cleanup patch for libxlDomainDetachNetDevice

https://www.redhat.com/archives/libvir-list/2016-March/msg00926.html

which I incorrectly modified before pushing as commit b5534e53. My
modification caused network devices of type hostdev to no longer
be removed. This patch changes b5534e53 to resemble Chunyan's
original, correct patch.

9 years agolibxl: fix attaching net device of type hostdev
Jim Fehlig [Wed, 30 Mar 2016 20:57:29 +0000 (14:57 -0600)]
libxl: fix attaching net device of type hostdev

Chunyan sent a correct patch to fix a resource leak on error in
libxlDomainAttachNetDevice

https://www.redhat.com/archives/libvir-list/2016-March/msg00924.html

I made what was thought to be an improvement and pushed the patch as
commit e6336442. As it turns out, my change broke adding net devices
that are actually hostdevs to the list of nets in virDomainDef. This
patch changes e6336442 to resemble Chunyan's original, correct
patch.

9 years agobuild: workaround broken SASL header (again)
Fabiano Fidêncio [Wed, 30 Mar 2016 06:52:38 +0000 (08:52 +0200)]
build: workaround broken SASL header (again)

Compilation for xdg-app failed due to a buggy SASL headers present on
the used runtime (org.gnome.Sdk 3.18).

In file included from rpc/virnetsaslcontext.h:24:0,
                 from rpc/virnetsaslcontext.c:25:
/usr/include/sasl/sasl.h:230:38: error: unknown type name 'size_t'
 typedef void *sasl_realloc_t(void *, size_t);
                                      ^
/usr/include/sasl/sasl.h:235:5: error: unknown type name 'sasl_realloc_t'
     sasl_realloc_t *,

Use the same workaround as commit 1be3dfd did.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoqemuProcessVerifyGuestCPU: Avoid coverity false positive
Michal Privoznik [Thu, 31 Mar 2016 14:45:11 +0000 (16:45 +0200)]
qemuProcessVerifyGuestCPU: Avoid coverity false positive

We use _LAST items in enums to mark the last position in given
enum. Now, if and enum is passed to switch(), compiler checks
that all the values from enum occur in 'case' enumeration.
Including _LAST. But coverity spots it's a dead code. And it
really is. So to resolve this, we tend to put a comment just
above 'case ..._LAST' notifying coverity that we know this is a
dead code but we want to have it that way.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirPerfReadEvent: Prefer saferead over read
Michal Privoznik [Thu, 31 Mar 2016 14:43:08 +0000 (16:43 +0200)]
virPerfReadEvent: Prefer saferead over read

Do I really need to explain why?
Well, if read() is interrupted int the middle of reading, we will
never read the rest (even though it's highly unlikely as we are
reading just 8 bytes).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodocs: Make most headers a bit smaller
Andrea Bolognani [Wed, 30 Mar 2016 13:31:20 +0000 (15:31 +0200)]
docs: Make most headers a bit smaller

Headers are bold already, so the font doesn't need to be that
big to draw attention.

9 years agodocs: Use bold text for all headers
Andrea Bolognani [Wed, 30 Mar 2016 13:32:34 +0000 (15:32 +0200)]
docs: Use bold text for all headers

All headers except for <h1> were already bold: make it bold as
well to increase visual consistency.

9 years agodocs: Don't use bold text for menu entries
Andrea Bolognani [Wed, 30 Mar 2016 12:21:00 +0000 (14:21 +0200)]
docs: Don't use bold text for menu entries

The menu should not take the focus away from the actual contents.

9 years agodocs: Make menu entries smaller
Andrea Bolognani [Wed, 30 Mar 2016 12:10:09 +0000 (14:10 +0200)]
docs: Make menu entries smaller

The menu should not take the focus away from the actual contents.

9 years agodocs: Don't use <strong> in headers
Andrea Bolognani [Wed, 30 Mar 2016 09:28:31 +0000 (11:28 +0200)]
docs: Don't use <strong> in headers

There's only one instance of that happening, and it looks
kinda off. Get rid of it, along with the corresponding
CSS rules.

9 years agodocs: Remove empty CSS rule
Andrea Bolognani [Wed, 30 Mar 2016 09:37:06 +0000 (11:37 +0200)]
docs: Remove empty CSS rule

9 years agodocs: Adjust vertical whitespace in CSS
Andrea Bolognani [Wed, 30 Mar 2016 09:33:58 +0000 (11:33 +0200)]
docs: Adjust vertical whitespace in CSS

Ensure all CSS rules are separated with a single blank line.

9 years agoremote: Add flags to remote_protocol-structs
Martin Kletzander [Thu, 31 Mar 2016 12:05:34 +0000 (14:05 +0200)]
remote: Add flags to remote_protocol-structs

Caused by 3b6c8185328f.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirDomain{Get,Set}PerfEvents: Grab job
Michal Privoznik [Thu, 31 Mar 2016 05:21:11 +0000 (07:21 +0200)]
virDomain{Get,Set}PerfEvents: Grab job

Even though we have the machine locked throughout whole APIs we
are querying/modifying domain internal state. We should grab a
job whilst doing that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomain{Get,Set}PerfEvents: support --config --live --current
Michal Privoznik [Wed, 30 Mar 2016 16:33:29 +0000 (18:33 +0200)]
virDomain{Get,Set}PerfEvents: support --config --live --current

Now that we have @flags we can support changing perf events just
in active or inactive configuration regardless of the other.
Previously, calling virDomainSetPerfEvents set events in both
active and inactive configuration at once. Even though we allow
users to set perf events that are to be enabled once domain is
started up. The virDomainGetPerfEvents API was flawed too. It
returned just runtime info.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Make perf accept event list separated by commas
Michal Privoznik [Wed, 30 Mar 2016 15:56:02 +0000 (17:56 +0200)]
virsh: Make perf accept event list separated by commas

Everywhere else we use a comma separated list. There's no good
reason to make 'perf' command an exception. Currently, it accepts
string list separated by '|'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Prefer VIRSH_COMMON_OPT_DOMAIN_FULL over full enumeration
Michal Privoznik [Wed, 30 Mar 2016 15:45:37 +0000 (17:45 +0200)]
virsh: Prefer VIRSH_COMMON_OPT_DOMAIN_FULL over full enumeration

We have a macro that does exactly what is done via full
enumeration.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomain{Get,Set}PerfEvents: Add @flags argument
Michal Privoznik [Wed, 30 Mar 2016 15:40:50 +0000 (17:40 +0200)]
virDomain{Get,Set}PerfEvents: Add @flags argument

I've noticed that these APIs are missing @flags argument. Even
though we don't have a use for them, it's our policy that every
new API must have @flags.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoremoteDomainGetPerfEvents: Re-indent
Michal Privoznik [Wed, 30 Mar 2016 15:40:10 +0000 (17:40 +0200)]
remoteDomainGetPerfEvents: Re-indent

There are few lines off the indentation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: command: Split up formatting of -numa and memory devices
Peter Krempa [Thu, 24 Mar 2016 14:56:16 +0000 (15:56 +0100)]
qemu: command: Split up formatting of -numa and memory devices

They recently were extracted to a separate function. They don't belong
together though. Since -numa formatting is pretty compact, move it to
the main function and rename qemuBuildNumaCommandLine to
qemuBuildMemoryDeviceCommandLine.

9 years agoqemu: command: Pass numad nodeset when formatting memory devices at boot
Peter Krempa [Thu, 24 Mar 2016 15:05:11 +0000 (16:05 +0100)]
qemu: command: Pass numad nodeset when formatting memory devices at boot

When starting up a VM libvirtd asks numad to place the VM in case of
automatic nodeset. The nodeset would not be passed to the memory device
formatter and the user would get an error.

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

9 years agoqemu_process: add check for hyperv features
Pavel Hrdina [Tue, 29 Mar 2016 13:17:45 +0000 (15:17 +0200)]
qemu_process: add check for hyperv features

Commit 7068b56c introduced several hyperv features.  Not all hyperv
features are supported by old enough kernels and we shouldn't allow to
start a guest if kernel doesn't support any of the hyperv feature.

There is one exception, for backward compatibility we cannot error out
if one of the RELAXED, VAPIC or SPINLOCKS isn't supported, for the same
reason we ignore invtsc, to not break restoring saved domains with older
libvirt.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoqemu_process: skip only cpu features
Pavel Hrdina [Tue, 29 Mar 2016 13:13:52 +0000 (15:13 +0200)]
qemu_process: skip only cpu features

This check is there to allow restore saved domain with older libvirt
where we included invtsc by default for host-passthrough model.  Don't
skip the whole function, but only the part that checks for invtsc.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodocs: fix qemu version for hyperv features
Pavel Hrdina [Tue, 29 Mar 2016 11:10:12 +0000 (13:10 +0200)]
docs: fix qemu version for hyperv features

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agohost-validate: Fix suggestion for missing cpu cgroup
Andrea Bolognani [Tue, 29 Mar 2016 16:40:34 +0000 (18:40 +0200)]
host-validate: Fix suggestion for missing cpu cgroup

If the cpu cgroup is not found when validating an host for
LXC support, virt-host-validate will suggest to enable the
CONFIG_CGROUP_SCHED kconfig option.

The appropriate option is really CONFIG_CGROUP_CPU. The
QEMU checks already get that right, so no changes needed.

9 years agonss: FreeBSD support
Roman Bogorodskiy [Sun, 27 Mar 2016 18:07:10 +0000 (21:07 +0300)]
nss: FreeBSD support

 * tools/nss/libvirt_nss.[ch]: add BSD-comptabile wrappers and
   register via the nss_module_register() interface
 * m4/virt-nss.m4: add checks if we're building NSS for FreeBSD
 * tools/Makefile.am: handle target library name differences, as
   Linux needs libnss_libvirt.so.2 and FreeBSD needs
   nss_libvirt.so.1. Also, different syms files have to be used
   as Linux needs to export all the methods while FreeBSD
   only needs to have nss_module_register()
 * tests/nsstest.c, tests/nssmock.c: s/__linux__/NSS/
 * tests/nssmock.c: pass int instead of mode_t to va_arg() to please
   gcc 4.8
 * libvirt_nss_bsd.syms: FreeBSD syms file

9 years agolibxl: only disable domain death events in libxlDomainCleanup
Jim Fehlig [Mon, 28 Mar 2016 20:17:13 +0000 (14:17 -0600)]
libxl: only disable domain death events in libxlDomainCleanup

Remove disabling domain death events from libxlDomainStart error
path. The domain death event is already disabled in libxlDomainCleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: fix resource leaks in libxlDomainStart error paths
Chunyan Liu [Mon, 28 Mar 2016 19:55:42 +0000 (13:55 -0600)]
libxl: fix resource leaks in libxlDomainStart error paths

libxlDomainStart allocates and reserves resources that were not
being released in error paths. libxlDomainCleanup already handles
the job of releasing resources, and libxlDomainStart should call
it when encountering a failure.

Change the error handling logic to call libxlDomainCleanup on
failure. This includes acquiring the lease sooner and allowing
it to be released in libxlDomainCleanup on failure, similar to
the way other resources are reclaimed. With the lease now
released in libxlDomainCleanup, the release_dom label can be
renamed to cleanup_dom to better reflect its changed semantics.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: rename cleanup_dom label
Jim Fehlig [Mon, 28 Mar 2016 19:47:07 +0000 (13:47 -0600)]
libxl: rename cleanup_dom label

Rename cleanup_dom label to destroy_dom, which better describes what
it does.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoconf: Remove now unused virDomainIOThreadIDMap
Peter Krempa [Mon, 21 Mar 2016 16:08:00 +0000 (17:08 +0100)]
conf: Remove now unused virDomainIOThreadIDMap

9 years agoconf: decrease iterations complexity when formatting iothreads
Peter Krempa [Mon, 21 Mar 2016 16:04:35 +0000 (17:04 +0100)]
conf: decrease iterations complexity when formatting iothreads

Create a bitmap of iothreads that have scheduler info set so that the
transformation algorithm does not have to iterate the empty bitmap many
times. By reusing self-expanding bitmaps the bitmap size does not need
to be pre-calculated.

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

9 years agoutil: bitmap: Introduce self-expanding bitmap APIs
Peter Krempa [Fri, 18 Mar 2016 14:41:59 +0000 (15:41 +0100)]
util: bitmap: Introduce self-expanding bitmap APIs

In some cases it's impractical to use the regular APIs as the bitmap
size needs to be pre-declared. These new APIs allow to use bitmaps that
self expand.

The new code adds a property to the bitmap to track the allocation of
memory so that VIR_RESIZE_N can be used.

9 years agoperf: fix build on non-Linux
Roman Bogorodskiy [Tue, 29 Mar 2016 16:23:46 +0000 (19:23 +0300)]
perf: fix build on non-Linux

 * Sync stubbed functions with prototypes
 * Add missing ATTRIBUTE_UNUSED where needed

Pushing under the build breaker rule.

9 years agoqemu: Fix /proc/**/stat parsing
Jiri Denemark [Tue, 29 Mar 2016 13:35:19 +0000 (15:35 +0200)]
qemu: Fix /proc/**/stat parsing

Since commit v1.3.2-119-g1e34a8f which enabled debug-threads in QEMU
qemuGetProcessInfo would fail to parse stats for any thread with a space
in its name.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirsh: blockpull: Support --bytes and scaled integers
Peter Krempa [Thu, 17 Mar 2016 12:41:00 +0000 (13:41 +0100)]
virsh: blockpull: Support --bytes and scaled integers

Use vshBlockJobOptionBandwidth to parse the bandwidth value which will
allow users to specify bandwidth in bytes or as a scaled integer.

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

9 years agovirsh: blockcopy: Support --bytes and scaled integers
Peter Krempa [Thu, 17 Mar 2016 12:40:30 +0000 (13:40 +0100)]
virsh: blockcopy: Support --bytes and scaled integers

Use vshBlockJobOptionBandwidth to parse the bandwidth value which will
allow users to specify bandwidth in bytes or as a scaled integer.

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

9 years agovirsh: blockcommit: Support --bytes and scaled integers
Peter Krempa [Thu, 17 Mar 2016 12:40:04 +0000 (13:40 +0100)]
virsh: blockcommit: Support --bytes and scaled integers

Use vshBlockJobOptionBandwidth to parse the bandwidth value which will
allow users to specify bandwidth in bytes or as a scaled integer.

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

9 years agovirsh: blockjob: Support --bytes and scaled integers as bandwidth
Peter Krempa [Tue, 29 Mar 2016 13:52:10 +0000 (15:52 +0200)]
virsh: blockjob: Support --bytes and scaled integers as bandwidth

Use vshBlockJobOptionBandwidth to parse the bandwidth value which will
allow users to specify bandwidth in bytes or as a scaled integer.

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

9 years agovsh: Introduce helper to parse --bandwidth
Peter Krempa [Tue, 29 Mar 2016 13:47:40 +0000 (15:47 +0200)]
vsh: Introduce helper to parse --bandwidth

Historically we've used 'unsigned long' and allowed wrapping of negative
numbers for bandwidth values. Add a helper that will simplify adding
support for scaled integers and support for byte granularity while
keeping the compatibility with the older approach.

9 years agovsh: Refactor vshCommandOptScaledInt
Peter Krempa [Thu, 17 Mar 2016 14:45:09 +0000 (15:45 +0100)]
vsh: Refactor vshCommandOptScaledInt

Fix control flow and spacing issues.

9 years agovsh: Tweak error message for scaled integers
Peter Krempa [Thu, 17 Mar 2016 14:40:43 +0000 (15:40 +0100)]
vsh: Tweak error message for scaled integers

It was too similar to the non-scaled alternative.

before:
error: Numeric value 'abc' for <size> option is malformed or out of range
after:
error: Scaled numeric value 'abc' for <size> option is malformed or out of range

9 years agoqemu: domain: Move and export qemuDomainDiskChainElement(Prepare|Revoke)
Peter Krempa [Mon, 29 Feb 2016 14:39:57 +0000 (15:39 +0100)]
qemu: domain: Move and export qemuDomainDiskChainElement(Prepare|Revoke)

Move the function to qemu_domain.c and export them for further use.

9 years agoqemu: Refactor qemuDomainPrepareDiskChainElement
Peter Krempa [Mon, 29 Feb 2016 14:29:32 +0000 (15:29 +0100)]
qemu: Refactor qemuDomainPrepareDiskChainElement

Now that there are only two elements in the enum, let's change it to a
bool and rename the function similarly to the one added in previous
commit.

9 years agoqemu: Split image access revoking from qemuDomainPrepareDiskChainElement
Peter Krempa [Mon, 29 Feb 2016 14:17:55 +0000 (15:17 +0100)]
qemu: Split image access revoking from qemuDomainPrepareDiskChainElement

Introduce qemuDomainDiskChainElementRevoke that revokes the access
rather than having a flag to do so.

9 years agoqemu: Kill qemuDiskPathToAlias
Peter Krempa [Fri, 26 Feb 2016 15:29:58 +0000 (16:29 +0100)]
qemu: Kill qemuDiskPathToAlias

The function has terrible semantics. Split it into two functions.

9 years agoqemu: monitor: Remove JSON impls of drive_add and drive_del
Peter Krempa [Fri, 11 Mar 2016 15:33:03 +0000 (16:33 +0100)]
qemu: monitor: Remove JSON impls of drive_add and drive_del

qemu won't ever add those functions directly to QMP. They will be
replaced with 'blockdev-add' and 'blockdev-del' eventually. At this time
there's no need to keep the stubs around.

Additionally the drive_del stub in JSON contained dead code in the
attempt to report errors. (VIR_ERR_OPERATION_UNSUPPORTED was never
reported). Since the text impl does have the same message it is reported
anyways.

9 years agoqemu: monitor: Drop qemuMonitorAttachDrive and leaves in call tree
Peter Krempa [Thu, 10 Mar 2016 14:34:37 +0000 (15:34 +0100)]
qemu: monitor: Drop qemuMonitorAttachDrive and leaves in call tree

Functions no longer required for attaching SCSI disks since
QEMU_CAPS_DEVICE is expected.

9 years agoqemu: hotplug: Assume support for -device in qemuDomainAttachSCSIDisk
Peter Krempa [Fri, 11 Mar 2016 14:51:17 +0000 (15:51 +0100)]
qemu: hotplug: Assume support for -device in qemuDomainAttachSCSIDisk

We've started to assume support for QEMU_CAPS_DEVICE. Doing so in the
SCSI disk hotplug code allows us to drop a lot of ugly legacy code.

9 years agobhyve: fix invalid hostsysinfo freeing
Maxim Nestratov [Mon, 28 Mar 2016 12:49:28 +0000 (15:49 +0300)]
bhyve: fix invalid hostsysinfo freeing

9 years agobhyve: cleanup unnecessary variables
Maxim Nestratov [Mon, 28 Mar 2016 12:24:49 +0000 (15:24 +0300)]
bhyve: cleanup unnecessary variables