1. 04 5月, 2014 1 次提交
  2. 02 5月, 2014 6 次提交
    • J
      Restore skipping of setting capacity · f1856eb6
      John Ferlan 提交于
      Commit id 'ac9a0963' refactored out the 'withCapacity' for the
      virStorageBackendUpdateVolInfo() API.  See:
      
      http://www.redhat.com/archives/libvir-list/2014-April/msg00043.html
      
      This resulted in a difference in how 'virsh vol-info --pool <poolName>
      <volume>' or 'virsh vol-list vol-list --pool <poolName> --details' outputs
      the capacity information for a directory pool with a qcow2 sparse file.
      
      For example, using the following XML
      
      mkdir /home/TestPool
      cat testpool.xml
      <pool type='dir'>
        <name>TestPool</name>
        <uuid>6bf80895-10b6-75a6-6059-89fdea2aefb7</uuid>
        <source>
        </source>
        <target>
          <path>/home/TestPool</path>
          <permissions>
            <mode>0755</mode>
            <owner>0</owner>
            <group>0</group>
          </permissions>
        </target>
      </pool>
      
      virsh pool-create testpool.xml
      virsh vol-create-as --pool TestPool temp_vol_1 \
            --capacity 1048576 --allocation 1048576 --format qcow2
      virsh vol-info --pool TestPool temp_vol_1
      
      Results in listing a Capacity value.  Prior to the commit, the value would
      be '1.0 MiB' (1048576 bytes). However, after the commit the output would be
      (for example) '192.50 KiB', which for my system was the size of the volume
      in my file system (eg 'ls -l TestPool/temp_vol_1' results in '197120' bytes
      or 192.50 KiB). While perhaps technically correct, it's not necessarily
      what the user expected (certainly virt-test didn't expect it).
      
      This patch restores the code to not update the target capacity for this path
      f1856eb6
    • J
      fix build with older gcc · 1055852a
      Ján Tomko 提交于
      Older gcc (4.1.2-55.el5, 4.2.1 on FreeBSD) reports bogus warnings:
      ../../src/conf/nwfilter_conf.c:2111: warning: 'protocol' may be used
      uninitialized in this function
      ../../src/conf/nwfilter_conf.c:2110: warning: 'dataProtocolID' may be
      used uninitialized in this function
      
      Initialize them to NULL to make the compiler happy.
      1055852a
    • E
      storage: reject negative indices · 5c05e2b1
      Eric Blake 提交于
      Commit f22b7899 stumbled across a difference between 32-bit and
      64-bit platforms when parsing "-1" as an int.  Now that we've
      fixed that difference, it's time to fix the testsuite.
      
      * src/util/virstoragefile.c (virStorageFileParseChainIndex):
      Require a positive index.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5c05e2b1
    • E
      util: new stricter unsigned int parsing · 7b045c8c
      Eric Blake 提交于
      strtoul() is required to parse negative numbers as their
      twos-complement positive counterpart.  But sometimes we want
      to reject negative numbers.  Add new functions to do this.
      The 'p' suffix is a mnemonic for 'positive' (technically it
      also parses 0, but 'non-negative' doesn't lend itself to a
      nice one-letter suffix).
      
      * src/util/virstring.h (virStrToLong_uip, virStrToLong_ulp)
      (virStrToLong_ullp): New prototypes.
      * src/util/virstring.c (virStrToLong_uip, virStrToLong_ulp)
      (virStrToLong_ullp): New functions.
      * src/libvirt_private.syms (virstring.h): Export them.
      * tests/virstringtest.c (testStringToLong): Test them.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      7b045c8c
    • E
      util: fix uint parsing on 64-bit platforms · f18c02ec
      Eric Blake 提交于
      Commit f22b7899 called to light a long-standing latent bug: the
      behavior of virStrToLong_ui was different on 32-bit platforms
      than on 64-bit platforms.  Curse you, C type promotion and
      narrowing rules, and strtoul specification.  POSIX says that for
      a 32-bit long, strtol handles only 2^32 values [LONG_MIN to
      LONG_MAX] while strtoul handles 2^33 - 1 values [-ULONG_MAX to
      ULONG_MAX] with twos-complement wraparound for negatives.  Thus,
      parsing -1 as unsigned long produces ULONG_MAX, rather than a
      range error.  We WANT[1] this same shortcut for turning -1 into
      UINT_MAX when parsing to int; and get it for free with 32-bit
      long.  But with 64-bit long, ULONG_MAX is outside the range
      of int and we were rejecting it as invalid; meanwhile, we were
      silently treating -18446744073709551615 as 1 even though it
      textually exceeds INT_MIN.  Too bad there's not a strtoui() in
      libc that does guaranteed parsing to int, regardless of the size
      of long.
      
      The bug has been latent since 2007, introduced by Jim Meyering
      in commit 5d254191 in the attempt to eradicate unsafe use of
      strto[u]l when parsing ints and longs.  How embarrassing that we
      are only discovering it now - so I'm adding a testsuite to ensure
      that it covers all the corner cases we care about.
      
      [1] Ideally, we really want the caller to be able to choose whether
      to allow negative numbers to wrap around to their 2s-complement
      counterpart, as in strtoul, or to force a stricter input range
      of [0 to UINT_MAX] by rejecting negative signs; this will be added
      in a later patch for all three int types.
      
      This patch is tested on both 32- and 64-bit; the enhanced
      virstringtest passes on both platforms, while virstoragetest now
      reliably fails on both platforms instead of just 32-bit platforms.
      That test will be fixed later.
      
      * src/util/virstring.c (virStrToLong_ui): Ensure same behavior
      regardless of platform long size.
      * tests/virstringtest.c (testStringToLong): New function.
      (mymain): Comprehensively test string to long parsing.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f18c02ec
    • D
      Misc error reporting bugs in QEMU cli builder · dca027a9
      Daniel P. Berrange 提交于
      A couple of places in the QEMU XML -> ARGV conversion code
      raised an error but then forgot to return an error status
      due to missing gotos. While fixing this also tweak style
      of a couple of other error reports
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      dca027a9
  3. 01 5月, 2014 4 次提交
  4. 30 4月, 2014 4 次提交
  5. 29 4月, 2014 14 次提交
    • E
      conf: avoid null deref during storage probe · c9679edc
      Eric Blake 提交于
      Commit 5c43e2e0 introduced a NULL deref if there is a failure
      in virStorageFileGetMetadataInternal.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
      Fix error handling.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c9679edc
    • D
      Don't use SO_REUSEADDR on Win32 platforms · 37697d82
      Daniel P. Berrange 提交于
      SO_REUSEADDR on Windows is actually akin to SO_REUSEPORT
      on Linux/BSD. ie it allows 2 apps to listen to the same
      port at once. Thus we must not set it on Win32 platforms
      
      See http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621.aspxSigned-off-by: NDaniel P. Berrange <berrange@redhat.com>
      37697d82
    • M
      qemu: properly quit migration with abort_on_error · 837154a1
      Martin Kletzander 提交于
      When EIO comes to qemu while it's replying to
      qemuMigrationUpdateJobStatus(), qemu blocks, the migration of RAM can
      complete in the meantime, and when qemu unblocks, it sends us
      BLOCK_IO_ERROR plus migrations "status": "complete".  Even though we
      act upon the BLOCK_IO_ERROR by setting the proper state of the domain,
      the call still waits for the proper reply on monitor for query_migrate
      and after it gets it, it checks that migration is completed and the
      migration is finished.  This is what abort_on_error flag was meant for
      (we can migrate with these errors, but this flag must inhibit such
      behaviour).  Changing the order of the steps guarantees the flag works
      properly.
      
      Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1045833Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      837154a1
    • M
      qemu: don't call virFileExists() for network type disks · f6ec6af8
      Martin Kletzander 提交于
      Based on suggestion from Eric [1], because it might not get cleaned up
      before the release, so to avoid potential errors.
      
      [1] https://www.redhat.com/archives/libvir-list/2014-April/msg00929.htmlSigned-off-by: NMartin Kletzander <mkletzan@redhat.com>
      f6ec6af8
    • S
      storage_backend_rbd: Correct argument order to rbd_create3 · 4cd508ba
      Steven McDonald 提交于
      The stripe_unit and stripe_count arguments are passed to rbd_create3 in
      the wrong order, resulting in a stripe size of 1 byte with 4194304
      stripes on newly created RBD volumes.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1092208Signed-off-by: NSteven McDonald <steven.mcdonald@anchor.net.au>
      4cd508ba
    • E
      enforce sane readdir usage · eae00fb5
      Eric Blake 提交于
      Now that all clients have been adjusted, ensure that no future
      misuse of readdir is introduced into the code base.
      
      * cfg.mk (sc_prohibit_readdir): New rule.
      * src/util/virfile.c (virDirRead): Exempt the wrapper.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      eae00fb5
    • L
      network: use virDirRead in networkMigrateStateFiles · a4315234
      Laine Stump 提交于
      This attempts to follow the same variable name and usage patterns as
      the other conversions to virDirRead().
      a4315234
    • E
      storage: use virDirRead API · 56a03233
      Eric Blake 提交于
      More instances of failure to report (unlikely) readdir errors.
      In one case, I chose to ignore them, given that a readdir error
      would be no different than timing out on the loop, where the
      fallback path behaves correctly either way.
      
      * src/storage/storage_backend.c (virStorageBackendStablePath):
      Ignore readdir errors.
      * src/storage/storage_backend_fs.c
      (virStorageBackendFileSystemRefresh): Report readdir errors.
      * src/storage/storage_backend_iscsi.c
      (virStorageBackendISCSIGetHostNumber): Likewise.
      * src/storage/storage_backend_scsi.c (getNewStyleBlockDevice)
      (getBlockDevice, virStorageBackendSCSIFindLUs): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      56a03233
    • E
      drivers: use virDirRead API · ddcf4730
      Eric Blake 提交于
      Convert all remaining clients of readdir to use the new
      interface, so that we can ensure (unlikely) errors while
      reading a directory are reported.
      
      * src/openvz/openvz_conf.c (openvzAssignUUIDs): Use new
      interface.
      * src/parallels/parallels_storage.c (parallelsFindVolumes)
      (parallelsFindVmVolumes): Report readdir failures.
      * src/qemu/qemu_driver.c (qemuDomainSnapshotLoad): Ignore readdir
      failures.
      * src/secret/secret_driver.c (loadSecrets): Likewise.
      * src/qemu/qemu_hostdev.c
      (qemuHostdevHostSupportsPassthroughVFIO): Report readdir failures.
      * src/xen/xen_inotify.c (xenInotifyOpen): Likewise.
      * src/xen/xm_internal.c (xenXMConfigCacheRefresh): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ddcf4730
    • E
      util: use virDirRead API · ac1d42ac
      Eric Blake 提交于
      In making the conversion to the new API, I fixed a couple bugs:
      virSCSIDeviceGetSgName would leak memory if a directory
      unexpectedly contained multiple entries;
      virNetDevTapGetRealDeviceName could report a spurious error
      from a stale errno inherited before starting the readdir search.
      
      The decision on whether to store the result of virDirRead into
      a variable is based on whether the end of the loop falls through
      to cleanup code automatically.  In some cases, we have loops that
      are documented to return NULL on failure, and which raise an
      error on most failure paths but not in the case where the directory
      was unexpectedly empty; it may be worth a followup patch to
      explicitly report an error if readdir was successful but the
      directory was empty, so that a NULL return always has an error set.
      
      * src/util/vircgroup.c (virCgroupRemoveRecursively): Use new
      interface.
      (virCgroupKillRecursiveInternal, virCgroupSetOwner): Report
      readdir failures.
      * src/util/virfile.c (virFileLoopDeviceOpenSearch)
      (virFileNBDDeviceFindUnused, virFileDeleteTree): Use new
      interface.
      * src/util/virnetdevtap.c (virNetDevTapGetRealDeviceName):
      Properly check readdir errors.
      * src/util/virpci.c (virPCIDeviceIterDevices)
      (virPCIDeviceFileIterate, virPCIGetNetName): Report readdir
      failures.
      (virPCIDeviceAddressIOMMUGroupIterate): Use new interface.
      * src/util/virscsi.c (virSCSIDeviceGetSgName): Report readdir
      failures, and avoid memory leak.
      (virSCSIDeviceGetDevName): Report readdir failures.
      * src/util/virusb.c (virUSBDeviceSearch): Report readdir
      failures.
      * src/util/virutil.c (virGetFCHostNameByWWN)
      (virFindFCHostCapableVport): Report readdir failures.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ac1d42ac
    • E
      conf: use virDirRead API · 6b9f40e8
      Eric Blake 提交于
      When reading configuration files, we were silently ignoring
      directory read failures.  While unlikely, we might as well
      report them.
      
      * src/conf/domain_conf.c (virDomainObjListLoadAllConfigs): Report
      readdir errors.
      * src/conf/network_conf.c (virNetworkLoadAllState)
      (virNetworkLoadAllConfigs): Likewise.
      * src/conf/nwfilter_conf.c (virNWFilterLoadAllConfigs): Likewise.
      * src/conf/storage_conf.c (virStoragePoolLoadAllConfigs):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6b9f40e8
    • N
      nodeinfo: use virDirRead API · 92cf75df
      Natanael Copa 提交于
      This makes sure that errno is reset before readdir is called, even if
      the loop does a 'continue'.
      
      This fixes issue with musl libc which sets errno on sscanf. The
      following 'continue' makes the errno be set before calling readdir.
      Signed-off-by: NNatanael Copa <ncopa@alpinelinux.org>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      92cf75df
    • N
      util: introduce virDirRead wrapper for readdir · 1ce2f1a4
      Natanael Copa 提交于
      Introduce a wrapper for readdir. This helps us make sure that we always
      set errno before calling readdir and it will make sure errors are
      properly logged.
      Signed-off-by: NNatanael Copa <ncopa@alpinelinux.org>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1ce2f1a4
    • J
      xen: ensure /usr/sbin/xend exists before checking status · 4f70ae24
      Jim Fehlig 提交于
      With xend on the way out, installations may not even have
      /usr/sbin/xend, which results in the following error when the
      drivers are probed
      
      2014-04-28 18:21:19.271+0000: 22129: error : virCommandWait:2426 :
      internal error: Child process (/usr/sbin/xend status) unexpected exit
      status 127: libvirt:  error : cannot execute binary /usr/sbin/xend:
      No such file or directory
      
      Check for existence of /usr/sbin/xend before trying to run it with
      the 'status' option.
      4f70ae24
  6. 28 4月, 2014 5 次提交
  7. 27 4月, 2014 6 次提交
    • L
      network: centralize check for active network during interface attach · 34cc3b2f
      Laine Stump 提交于
      The check for a network being active during interface attach was being
      done individually in several places (by both the lxc driver and the
      qemu driver), but those places were too specific, leading to it *not*
      being checked when allocating a connection/device from a macvtap or
      hostdev network.
      
      This patch puts a single check in networkAllocateActualDevice(), which
      is always called before the any network interface is attached to any
      type of domain. It also removes all the other now-redundant checks
      from the lxc and qemu drivers.
      
      NB: the following patches are prerequisites for this patch, in the
      case that it is backported to any branch:
      
        440beeb7 network: fix virNetworkObjAssignDef and persistence
        8aaa5b68 network: create statedir during driver initialization
        b9e95491 network: change location of network state xml files
        411c5486 network: set macvtap/hostdev networks active if their state
                file exists
      
      This fixes:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=880483
      34cc3b2f
    • L
      network: set macvtap/hostdev networks active if their state file exists · 411c5486
      Laine Stump 提交于
      libvirt attempts to determine at startup time which networks are
      already active, and set their active flags. Previously it has done
      this by assuming that all networks are inactive, then setting the
      active flag if the network has a bridge device associated with it and
      that bridge device exists. This is not useful for macvtap and hostdev
      based networks, since they do not use a bridge device.
      
      Of course the reason that such a check had to be done was that the
      presence of a status file in the network "stateDir" couldn't be
      trusted as an indicator of whether or not a network was active. This
      was due to the network driver mistakenly using
      /var/lib/libvirt/network to store the status files, rather than
      /var/run/libvirt/network (similar to what is done by every other
      libvirt driver that stores status xml for its objects). The difference
      is that /var/run is cleared out when the host reboots, so you can be
      assured that the state file you are seeing isn't just left over from a
      previous boot of the host.
      
      Now that the network driver has been switched to using
      /var/run/libvirt/network for status, we can also modify it to assume
      that any network with an existing status file is by definition active
      - we do this when reading the status file. To fine tune the results,
      networkFindActiveConfigs() is changed to networkUpdateAllState(),
      and only sets active = 0 if the conditions for particular network
      types are *not* met.
      
      The result is that during the first run of libvirtd after the host
      boots, there are no status files, so no networks are active. Any time
      libvirtd is restarted, any network with a status file will be marked
      as active (unless the network uses a bridge device and that device for
      some reason doesn't exist).
      411c5486
    • L
      network: change location of network state xml files · b9e95491
      Laine Stump 提交于
      For some reason these have been stored in /var/lib, although other
      drivers (e.g. qemu and lxc) store their state files in /var/run.
      
      It's much nicer to store state files in /var/run because it is
      automatically cleared out when the system reboots. We can then use
      existence of the state file as a convenient indicator of whether or
      not a particular network is active.
      
      Since changing the location of the state files by itself will cause
      problems in the case of a *live* upgrade from an older libvirt that
      uses /var/lib (because current status of active networks will be
      lost), the network driver initialization has been modified to migrate
      any network state files from /var/lib to /var/run.
      
      This will not help those trying to *downgrade*, but in practice this
      will only be problematic in two cases
      
      1) If there are networks with network-wide bandwidth limits configured
         *and in use* by a guest during a downgrade to "old" libvirt. In this
         case, the class ID's used for that network's tc rules, as well as
         the currently in-use bandwidth "floor" will be forgotten.
      
      2) If someone does this: 1) upgrade libvirt, 2) downgrade libvirt, 3)
         modify running state of network (e.g. add a static dhcp host, etc),
         4) upgrade. In this case, the modifications to the running network
         will be lost (but not any persistent changes to the network's
         config).
      b9e95491
    • L
      network: create statedir during driver initialization · 8aaa5b68
      Laine Stump 提交于
      This directory should be created when the network driver is first
      started up, not just when a dhcp daemon is run. This hasn't posed a
      problem in the past, because the directory has always been
      pre-existing.
      8aaa5b68
    • L
      network: fix virNetworkObjAssignDef and persistence · 440beeb7
      Laine Stump 提交于
      Experimentation showed that if virNetworkCreateXML() was called for a
      network that was already defined, and then the network was
      subsequently shutdown, the network would continue to be persistent
      after the shutdown (expected/desired), but the original config would
      be lost in favor of the transient config sent in with
      virNetworkCreateXML() (which would then be the new persistent config)
      (obviously unexpected/not desired).
      
      To fix this, virNetworkObjAssignDef() has been changed to
      
      1) properly save/free network->def and network->newDef for all the
      various combinations of live/active/persistent, including some
      combinations that were previously considered to be an error but didn't
      need to be (e.g. setting a "live" config for a network that isn't yet
      active but soon will be - that was previously considered an error,
      even though in practice it can be very useful).
      
      2) automatically set the persistent flag whenever a new non-live
      config is assigned to the network (and clear it when the non-live
      config is set to NULL). the libvirt network driver no longer directly
      manipulates network->persistent, but instead relies entirely on
      virNetworkObjAssignDef() to do the right thing automatically.
      
      After this patch, the following sequence will behave as expected:
      
      virNetworkDefineXML(X)
      virNetworkCreateXML(X') (same name but some config different)
      virNetworkDestroy(X)
      
      At the end of these calls, the network config will remain as it was
      after the initial virNetworkDefine(), whereas previously it would take
      on the changes given during virNetworkCreateXML().
      
      Another effect of this tighter coupling between a) setting a !live def
      and b) setting/clearing the "persistent" flag, is that future patches
      which change the details of network lifecycle management
      (e.g. upcoming patches to fix detection of "active" networks when
      libvirtd is restarted) will find it much more difficult to break
      persistence functionality.
      440beeb7
    • D
      build: -avoid-version on libvirt_driver_nwfilter · 014f317b
      Dwight Engen 提交于
      This fixes the following make rpm warning:
      
      warning: Installed (but unpackaged) file(s) found:
         /usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so.0
         /usr/lib64/libvirt/connection-driver/libvirt_driver_nwfilter.so.0.0.0
      
      introduced in comit 8d559864Signed-off-by: NDwight Engen <dwight.engen@oracle.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      014f317b