1. 18 11月, 2013 1 次提交
  2. 15 11月, 2013 1 次提交
  3. 08 11月, 2013 3 次提交
    • L
      pci: properly handle out-of-order SRIOV virtual functions · 88c1fcd5
      Laine Stump 提交于
      This resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1025397
      
      When virPCIGetVirtualFunctions created the list of an SRIOV Physical
      Function's (PF) Virtual Functions (VF), it had assumed that the order
      of "virtfn*" links returned by readdir() from the PF's sysfs directory
      was already in the correct order. Experience has shown that this is
      not always the case - it can be in alphabetical order (which would
      e.g. place virtfn11 before virtfn2) or even some seemingly random
      order (see the example in the bugzilla report)
      
      This results in 1) incorrect assumptions made by consumers of the
      output of the virt_functions list of virsh nodedev-dumpxml, and 2)
      setting MAC address and vlan tag on the wrong VF (since libvirt uses
      netlink to set mac address and vlan tag, netlink requires the VF#, and
      the function virPCIGetVirtualFunctionIndex() returns the wrong index
      due to the improperly ordered VF list).
      
      The solution provided by this patch is for virPCIGetVirtualFunctions
      to no longer scan the entire device directory in its natural order,
      but instead to check for links individually by name "virtfn%d" where
      %d starts at 0 and increases with each success. Since VFs are created
      contiguously by the kernel, this will guarantee that all VFs are
      found, and placed in the arry in the correct order.
      
      One note of use to the uninitiated is that VIR_APPEND_ELEMENT always
      either increments *num_virtual_functions or fails, so no this isn't an
      endless loop.
      
      (NB: the SRIOV_* defines at the top of virpci.c were removed
      because they are unnecessary and/or not used.)
      88c1fcd5
    • L
      util: use size_t instead of unsigned int for num_virtual_functions · 89e2a6c8
      Laine Stump 提交于
      This is a prerequisite to the fix for the fix to:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1025397
      
      num_virtual_functions needs to be size_t in order to use the
      VIR_APPEND_ELEMENT macro.
      89e2a6c8
    • S
      util: use -w flag when calling iptables · ba95426d
      Serge Hallyn 提交于
      When supported, ask iptables to wait rather than fail if it is in use
      by another caller (like ufw).
      
      (See https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1245322)
      Signed-off-by: NSerge Hallyn <serge.hallyn@ubuntu.com>
      ba95426d
  4. 07 11月, 2013 4 次提交
    • E
      storage: always probe type with buffer · 348b4e25
      Eric Blake 提交于
      This gets rid of another stat() per volume, as well as cutting
      bytes read in half, when populating the volumes of a directory
      pool during a pool refresh.  Not to mention that it provides an
      interface that can let gluster pools also probe file types.
      
      * src/util/virstoragefile.h (virStorageFileProbeFormatFromFD):
      Delete.
      (virStorageFileProbeFormatFromBuf): New prototype.
      (VIR_STORAGE_MAX_HEADER): New constant, based on...
      * src/util/virstoragefile.c (STORAGE_MAX_HEAD): ...old name.
      (vmdk4GetBackingStore, virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormat): Adjust clients.
      (virStorageFileProbeFormatFromFD): Delete.
      (virStorageFileProbeFormatFromBuf): Export.
      * src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
      Adjust client.
      * src/libvirt_private.syms (virstoragefile.h): Adjust exports.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      348b4e25
    • E
      storage: refactor backing chain division of labor · 3ead2e7d
      Eric Blake 提交于
      Future patches will want to learn metadata about a file using
      a buffer that was already parsed in order to probe the file's
      format.  Rather than reopening and re-reading the file, it makes
      sense to separate getting file contents from actually parsing
      those contents.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf)
      (virStorageFileGetMetadataFromFDInternal): New functions.
      (virStorageFileGetMetadataInternal): Hoist fstat() and read() into
      callers.
      (virStorageFileGetMetadataFromFD)
      (virStorageFileGetMetadataRecurse): Rework clients.
      * src/util/virstoragefile.h (virStorageFileGetMetadataFromBuf):
      New prototype.
      * src/libvirt_private.syms (virstoragefile.h): Export it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      3ead2e7d
    • E
      storage: avoid short reads while chasing backing chain · 5327fad4
      Eric Blake 提交于
      Our backing file chain code was not very robust to an ill-timed
      EINTR, which could lead to a short read causing us to randomly
      treat metadata differently than usual.  But the existing
      virFileReadLimFD forces an error if we don't read the entire
      file, even though we only care about the header of the file.
      So add a new virFile function that does what we want.
      
      * src/util/virfile.h (virFileReadHeaderFD): New prototype.
      * src/util/virfile.c (virFileReadHeaderFD): New function.
      * src/libvirt_private.syms (virfile.h): Export it.
      * src/util/virstoragefile.c (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Use it.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5327fad4
    • E
      storage: use simpler 'char *' · 5717ee6a
      Eric Blake 提交于
      'unsigned char *' makes sense if you are doing math on bytes and
      don't want to worry about wraparound from a signed 'char'; but
      since all we are doing is memcmp() or virReadBufInt*[LB]E(), which
      are both safe on either type of char, and since read() prefers to
      operate on 'char *', it's simpler to avoid casts by just typing
      things as 'char *' from the get-go.  [Technically, read can
      operate on an 'unsigned char *' thanks to the C rule that any
      pointer can be implicitly converted to 'char *' for legacy K&R
      compatibility; but where this patch saves us is if we try to use
      virfile.h functions that take 'char **' in order to allocate the
      buffer, where the compiler would barf on type mismatch.]
      
      * src/util/virstoragefile.c (FileTypeInfo): Avoid unsigned char.
      (cowGetBackingStore, qcow2GetBackingStoreFormat)
      (qcowXGetBackingStore, qcow1GetBackingStore)
      (qcow2GetBackingStore, vmdk4GetBackingStore, qedGetBackingStore)
      (virStorageFileMatchesMagic, virStorageFileMatchesVersion)
      (virStorageFileProbeFormatFromBuf, qcow2GetFeatures)
      (virStorageFileGetMetadataInternal)
      (virStorageFileProbeFormatFromFD): Simplify clients.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5717ee6a
  5. 05 11月, 2013 3 次提交
  6. 04 11月, 2013 5 次提交
  7. 21 10月, 2013 7 次提交
  8. 18 10月, 2013 1 次提交
  9. 16 10月, 2013 4 次提交
  10. 15 10月, 2013 5 次提交
    • C
      cgroup: leave blkio cgroup value checking to kernel · 521cec2a
      Chen Hanxiao 提交于
      The range of valid values for cgroup tunables has
      changed in the past and may change again in future
      kernels. Avoid hardcoding range checks in libvirt
      code, delegating range checking to the kernel itself.
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      521cec2a
    • C
      cgroup: show error when EINVAL is returned · 501476fc
      Chen Hanxiao 提交于
      When EINVAL is returned while changing a cgroups value, tell
      user that what values are invalid for the field.
      Signed-off-by: NChen Hanxiao <chenhanxiao@cn.fujitsu.com>
      501476fc
    • E
      maint: avoid 'const fooPtr' in virnet files · 955af4d4
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up remaining offenders in src/util.
      
      * src/util/virnetdev.h (virNetDevSetMAC)
      (virNetDevReplaceMacAddress, virNetDevValidateConfig)
      (virNetDevReplaceNetConfig): Use intended type.
      * src/util/virnetdevbandwidth.h (virNetDevBandwidthCopy)
      (virNetDevBandwidthPlug): Likewise.
      * src/util/virnetdevmacvlan.h (virNetDevMacVLanCreate)
      (virNetDevMacVLanCreateWithVPortProfile)
      (virNetDevMacVLanDeleteWithVPortProfile)
      (virNetDevMacVLanRestartWithVPortProfile)
      (virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
      * src/util/virnetdevopenvswitch.h (virNetDevOpenvswitchAddPort):
      Likewise.
      * src/util/virnetdevtap.h (virNetDevTapCreateInBridgePort):
      Likewise.
      * src/util/virnetdevvlan.h (virNetDevVlanEqual)
      (virNetDevVlanCopy): Likewise.
      * src/util/virnetdevvportprofile.h
      (virNetDevVPortProfileAssociate)
      (virNetDevVPortProfileDisassociate): Likewise.
      * src/util/virnetlink.h (virNetlinkEventRemoveCallback)
      (virNetlinkEventAddClient, virNetlinkEventRemoveClient):
      Likewise.
      * src/util/virnetdev.c (virNetDevSetMAC)
      (virNetDevReplaceMacAddress, virNetDevValidateConfig)
      (virNetDevReplaceNetConfig): Fix fallout.
      * src/util/virnetdevbandwidth.c (virNetDevBandwidthCopy)
      (virNetDevBandwidthPlug): Likewise.
      * src/util/virnetdevmacvlan.c (virNetDevMacVLanCreate)
      (virNetDevMacVLanCreateWithVPortProfile)
      (virNetDevMacVLanDeleteWithVPortProfile)
      (virNetDevMacVLanRestartWithVPortProfile)
      (virNetDevMacVLanVPortProfileRegisterCallback): Likewise.
      * src/util/virnetdevopenvswitch.c (virNetDevOpenvswitchAddPort):
      Likewise.
      * src/util/virnetdevtap.c (virNetDevTapCreateInBridgePort):
      Likewise.
      * src/util/virnetdevvlan.c (virNetDevVlanEqual)
      (virNetDevVlanCopy): Likewise.
      * src/util/virnetdevvportprofile.c
      (virNetDevVPortProfileAssociate)
      (virNetDevVPortProfileDisassociate)
      (virNetDevVPortProfileOpSetLink, virNetDevVPortProfileOpCommon)
      (virNetDevVPortProfileOp8021Qbg, virNetDevVPortProfileOp8021Qbh):
      Likewise.
      * src/util/virnetlink.c (virNetlinkEventRemoveCallback)
      (virNetlinkEventAddClient, virNetlinkEventRemoveClient):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      955af4d4
    • E
      maint: avoid 'const fooPtr' in several util files · 1b0bc416
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up offenders in src/util outside of the virnet namespace.
      
      Also, make a few virSocketAddr functions const-correct, for easier
      conversions in future patches.
      
      * src/util/virbuffer.h (virBufferError, virBufferUse)
      (virBufferGetIndent): Use intended type.
      * src/util/virmacaddr.h (virMacAddrCmp, virMacAddrCmpRaw)
      (virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast)
      (virMacAddrIsMulticast): Likewise.
      * src/util/virebtables.h (ebtablesAddForwardAllowIn)
      (ebtablesRemoveForwardAllowIn): Likewise.
      * src/util/virsocketaddr.h (virSocketAddrSetIPv4Addr): Drop
      incorrect const.
      (virMacAddrGetRaw, virSocketAddrFormat, virSocketAddrFormatFull):
      Make const-correct.
      (virSocketAddrMask, virSocketAddrMaskByPrefix)
      (virSocketAddrBroadcast, virSocketAddrBroadcastByPrefix)
      (virSocketAddrGetNumNetmaskBits, virSocketAddrGetIpPrefix)
      (virSocketAddrEqual, virSocketAddrIsPrivate)
      (virSocketAddrIsWildcard): Use intended type.
      * src/util/virbuffer.c (virBufferError, virBufferUse)
      (virBufferGetIndent): Fix fallout.
      * src/util/virmacaddr.c (virMacAddrCmp, virMacAddrCmpRaw)
      (virMacAddrSet, virMcAddrFormat, virMacAddrIsUnicast)
      (virMacAddrIsMulticast): Likewise.
      * src/util/virebtables.c (ebtablesAddForwardAllowIn)
      (ebtablesRemoveForwardAllowIn): Likewise.
      * src/util/virsocketaddr.c (virSocketAddrMask, virMacAddrGetRaw)
      (virSocketAddrMaskByPrefix, virSocketAddrBroadcast)
      (virSocketAddrBroadcastByPrefix, virSocketAddrGetNumNetmaskBits)
      (virSocketAddrGetIpPrefix, virSocketAddrEqual)
      (virSocketAddrIsPrivate, virSocketAddrIsWildcard)
      (virSocketAddrGetIPv4Addr, virSocketAddrGetIPv6Addr)
      (virSocketAddrFormat, virSocketAddrFormatFull): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      1b0bc416
    • E
      maint: avoid 'const fooPtr' in hashes · b43efdaa
      Eric Blake 提交于
      'const fooPtr' is the same as 'foo * const' (the pointer won't
      change, but it's contents can).  But in general, if an interface
      is trying to be const-correct, it should be using 'const foo *'
      (the pointer is to data that can't be changed).
      
      Fix up virhash to provide a const-correct interface: all actions
      that don't modify the table take a const table.  Note that in
      one case (virHashSearch), we actually strip const away - we aren't
      modifying the contents of the table, so much as associated data
      for ensuring that the code uses the table correctly (if this were
      C++, it would be a case for the 'mutable' keyword).
      
      * src/util/virhash.h (virHashKeyComparator, virHashEqual): Use
      intended type.
      (virHashSize, virHashTableSize, virHashLookup, virHashSearch):
      Make const-correct.
      * src/util/virhash.c (virHashEqualData, virHashEqual)
      (virHashLookup, virHashSize, virHashTableSize, virHashSearch)
      (virHashComputeKey): Fix fallout.
      * src/conf/nwfilter_params.c
      (virNWFilterFormatParameterNameSorter): Likewise.
      * src/nwfilter/nwfilter_ebiptables_driver.c
      (ebiptablesFilterOrderSort): Likewise.
      * tests/virhashtest.c (testHashGetItemsCompKey)
      (testHashGetItemsCompValue): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b43efdaa
  11. 14 10月, 2013 5 次提交
    • D
      Initialize threading & error layer in LXC controller · 97973ebb
      Daniel P. Berrange 提交于
      In Fedora 20, libvirt_lxc crashes immediately at startup with a
      trace
      
       #0  0x00007f0cddb653ec in free () from /lib64/libc.so.6
       #1  0x00007f0ce0e16f4a in virFree (ptrptr=ptrptr@entry=0x7f0ce1830058) at util/viralloc.c:580
       #2  0x00007f0ce0e2764b in virResetError (err=0x7f0ce1830030) at util/virerror.c:354
       #3  0x00007f0ce0e27a5a in virResetLastError () at util/virerror.c:387
       #4  0x00007f0ce0e28858 in virEventRegisterDefaultImpl () at util/virevent.c:233
       #5  0x00007f0ce0db47c6 in main (argc=11, argv=0x7fff4596c328) at lxc/lxc_controller.c:2352
      
      Normally virInitialize calls virErrorInitialize and
      virThreadInitialize, but we don't link to libvirt.so
      in libvirt_lxc, and nor did we ever call the error
      or thread initializers.
      
      I have absolutely no idea how this has ever worked, let alone
      what caused it to stop working in Fedora 20.
      
      In addition not all code paths from virLogSetFromEnv will
      ensure virLogInitialize is called correctly, which is another
      possible crash scenario.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      97973ebb
    • D
      Don't ignore all dbus connection errors · 6bd88600
      Daniel P. Berrange 提交于
      Previous commit
      
        commit 7ada155c
        Author: Gao feng <gaofeng@cn.fujitsu.com>
        Date:   Wed Sep 11 11:15:02 2013 +0800
      
          DBus: introduce virDBusIsServiceEnabled
      
      Made the cgroups code fallback to non-systemd based setup
      when dbus is not running. It was too big a hammer though,
      as it did not check what error code was received when the
      dbus connection failed. Thus it silently ignored serious
      errors from dbus such as "too many client connections",
      which should always be treated as fatal.
      
      We only want to ignore errors if the dbus unix socket does
      not exist, or if nothing is listening on it.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      6bd88600
    • D
      Fix flaw in detecting log format · 5787f0b9
      Daniel P. Berrange 提交于
      The log message regex has been
      
      [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug|info|warning|error :
      
      The precedence of '|' is high though, so this is equivalent to matching
      
         [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]{3}\+[0-9]{4}: [0-9]+: debug
      
      Or
      
         info
      
      Or
      
         warning
      
      Or
      
         error :
      
      Which is clearly not what it should have done. This caused the code to
      skip over things which are not log messages. The solution is to simply
      add brackets.
      
      A test case is also added to validate correctness.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      5787f0b9
    • D
      Add a method for closing the dbus system bus connection · 489beb0a
      Daniel P. Berrange 提交于
      If the dbus system bus connection is marked as private, then
      allow it to be closed.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      489beb0a
    • D
      Allow use of a private dbus bus connection · 0cb774f0
      Daniel P. Berrange 提交于
      The dbus_bus_get() function returns a shared bus connection that
      all libraries in a process can use. You are forbidden from calling
      close on this connection though, since you can never know if any
      other code might be using it.
      
      Add an option to use private dbus bus connections, if the app
      wants to be able to close the connection.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      0cb774f0
  12. 11 10月, 2013 1 次提交
    • B
      util: fix two virCompareLimitUlong bugs · 19e7c04d
      Bing Bu Cao 提交于
      The helper function virCompareLimitUlong compares limit values,
      where value of 0 is equal to unlimited. If the latter parameter is 0,
      it should return -1 instead of 1, hence the user can only set hard_limit when
      swap_hard_limit currently is unlimited.
      
      Worse, all callers pass 2 64-bit values, but on 32-bit platforms,
      the second argument was silently truncated to 32 bits, which
      could lead to incorrect computations.
      Signed-off-by: NBing Bu Cao <mars@linux.vnet.ibm.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      19e7c04d