1. 25 3月, 2013 2 次提交
    • O
      nodedev: Refactor the helpers · 4360a098
      Osier Yang 提交于
      This adds two util functions (virIsCapableFCHost and virIsCapableVport),
      and rename helper check_fc_host_linux as detect_scsi_host_caps,
      check_capable_vport_linux is removed, as it's abstracted to the util
      function virIsCapableVport. detect_scsi_host_caps nows detect both
      the fc_host and vport_ops capabilities. "stat(2)" is replaced with
      "access(2)" for saving.
      
      * src/util/virutil.h:
        - Declare virIsCapableFCHost and virIsCapableVport
      * src/util/virutil.c:
        - Implement virIsCapableFCHost and virIsCapableVport
      * src/node_device/node_device_linux_sysfs.c:
        - Remove check_capable_vport_linux
        - Rename check_fc_host_linux as detect_scsi_host_caps, and refactor
          it a bit to detect both fc_host and vport_os capabilities
      * src/node_device/node_device_driver.h:
        - Change/remove the related declarations
      * src/node_device/node_device_udev.c: (Use detect_scsi_host_caps)
      * src/node_device/node_device_hal.c: (Likewise)
      * src/node_device/node_device_driver.c (Likewise)
      4360a098
    • O
      util: Add one helper virReadFCHost to read the value of fc_host entry · 244ce462
      Osier Yang 提交于
      "open_wwn_file" in node_device_linux_sysfs.c is redundant, on one
      hand it duplicates work of virFileReadAll, on the other hand, it's
      waste to use a function for it, as there is no other users of it.
      So I don't see why the file opening work cannot be done in
      "read_wwn_linux".
      
      "read_wwn_linux" can be abstracted as an util function. As what all
      it does is to read the sysfs entry.
      
      So this patch removes "open_wwn_file", and abstract "read_wwn_linux"
      as an util function "virReadFCHost" (a more general name, because
      after changes, it can read each of the fc_host entry now).
      
      * src/util/virutil.h: (Declare virReadFCHost)
      * src/util/virutil.c: (Implement virReadFCHost)
      * src/node_device/node_device_linux_sysfs.c: (Remove open_wwn_file,
        and read_wwn_linux)
      src/node_device/node_device_driver.h: (Remove the declaration of
        read_wwn_linux, and the related macros)
      src/libvirt_private.syms: (Export virReadFCHost)
      244ce462
  2. 22 3月, 2013 2 次提交
  3. 21 3月, 2013 2 次提交
  4. 20 3月, 2013 3 次提交
  5. 19 3月, 2013 3 次提交
  6. 16 3月, 2013 1 次提交
    • E
      util: portably check for unchanged uid · 7af86379
      Eric Blake 提交于
      We've already scrubbed for comparisons of 'uid_t == -1' (which fail
      on platforms where uid_t is a u16), but another one snuck in.
      
      * src/util/virutil.c (virSetUIDGIDWithCaps): Correct uid comparison.
      * cfg.mk (sc_prohibit_risky_id_promotion): New rule.
      7af86379
  7. 15 3月, 2013 1 次提交
    • L
      util: fix clear_emulator_capabilities=0 · 49fa91b3
      Laine Stump 提交于
      My commit 7a2e845a (and its
      prerequisites) managed to effectively ignore the
      clear_emulator_capabilities setting in qemu.conf (visible in the code
      as the VIR_EXEC_CLEAR_CAPS flag when qemu is being exec'ed), with the
      result that the capabilities are always cleared regardless of the
      qemu.conf setting. This patch fixes it by passing the flag through to
      virSetUIDGIDWithCaps(), which uses it to decide whether or not to
      clear existing capabilities before adding in those that were
      requested.
      
      Note that the existing capabilities are *always* cleared if the new
      process is going to run as non-root, since the whole point of running
      non-root is to have the capabilities removed (it's still possible to
      maintain individual capabilities as needed using the capBits argument
      though).
      49fa91b3
  8. 14 3月, 2013 2 次提交
  9. 13 3月, 2013 1 次提交
    • D
      Add API for thread cancellation · a2997142
      Daniel P. Berrange 提交于
      Add a virThreadCancel function. This functional is inherently
      dangerous and not something we want to use in general, but
      integration with SELinux requires that we provide this stub.
      We leave out any Win32 impl to discourage further use and
      because obviously SELinux isn't enabled on Win32
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a2997142
  10. 08 3月, 2013 4 次提交
  11. 07 3月, 2013 2 次提交
  12. 06 3月, 2013 1 次提交
    • G
      util: fix a integer boundary error · b38a040a
      Guannan Ren 提交于
      A value which is equal to a integer maximum such as LLONG_MAX is
      a valid integer value.
      
      The patch fix the following error:
      1, virsh memtune vm --swap-hard-limit -1
      2, virsh start vm
      In debug mode, it shows error like:
      virScaleInteger:1813 : numerical overflow:\
                             value too large: 9007199254740991KiB
      b38a040a
  13. 04 3月, 2013 1 次提交
    • G
      util: use string libvirt to prefix error message instead of libvir · b95c13cd
      Guannan Ren 提交于
      BZ:https://bugzilla.redhat.com/show_bug.cgi?id=912021
      Without error handler set, virDefaultErrorFunc will be called, the
      error message is prefixed with "libvir:". It become a little better
      by using prefix "libvirt:" when working with upper application.
      
      For example:
      1, stop libvirtd daemon
      2, run virt-top.
      libvir: XML-RPC error : Failed to connect \
              socket to '/var/run/libvirt/libvirt-sock-ro': \
              No such file or directory
      libvirt: VIR_ERR_SYSTEM_ERROR: VIR_FROM_RPC: \
              Failed to connect socket to '/var/run/libvirt/libvirt-sock-ro': \
              No such file or directory
      b95c13cd
  14. 01 3月, 2013 1 次提交
    • M
      virnetdevmacvlan.c: Introduce mutex for macvlan creation · 1cf97c87
      Michal Privoznik 提交于
      Currently, after we removed the qemu driver lock, it may happen
      that two or more threads will start up a machine with macvlan and
      race over virNetDevMacVLanCreateWithVPortProfile(). However,
      there's a racy section in which we are generating a sequence of
      possible device names and detecting if they exits. If we found
      one which doesn't we try to create a device with that name.
      However, the other thread is doing just the same. Assume it will
      succeed and we must therefore fail. If this happens more than 5
      times (which in massive parallel startup surely will) we return
      -1 without any error reported. This patch is a simple hack to
      both of these problems. It introduces a mutex, so only one thread
      will enter the section, and if it runs out of possibilities,
      error is reported. Moreover, the number of retries is raised to 20.
      1cf97c87
  15. 28 2月, 2013 1 次提交
    • D
      Avoid spamming logs with cgroups warnings · 279336c5
      Daniel P. Berrange 提交于
      The code for putting the emulator threads in a separate cgroup
      would spam the logs with warnings
      
      2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 3
      2013-02-27 16:08:26.731+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 4
      2013-02-27 16:08:26.732+0000: 29624: warning : virCgroupMoveTask:887 : no vm cgroup in controller 6
      
      This is because it has only created child cgroups for 3 of the
      controllers, but was trying to move the processes from all the
      controllers. The fix is to only try to move threads in the
      controllers we actually created. Also remove the warning and
      make it return a hard error to avoid such lazy callers in the
      future.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      279336c5
  16. 27 2月, 2013 1 次提交
  17. 25 2月, 2013 4 次提交
  18. 20 2月, 2013 3 次提交
  19. 19 2月, 2013 1 次提交
    • J
      Avoid resetting errors in virTypedParamsFree · ee1d6d91
      Jiri Denemark 提交于
      The function does not report any errors so there should be no need too
      reset an existing error first. Moreover, virTypedParamsFree is mostly
      called in cleanup phase where it has the potential to reset any useful
      reported earlier.
      ee1d6d91
  20. 16 2月, 2013 4 次提交
    • J
      vircommand: Remove unnecessary sa_assert · 277aaeee
      John Ferlan 提交于
      Changes from commit '3178df9a' removed the need for the sa_assert(infd).
      277aaeee
    • E
      storage: don't follow backing chain symlinks too eagerly · d1333dd0
      Eric Blake 提交于
      If you have a qcow2 file /path1/to/file pointed to by symlink
      /path2/symlink, and pass qemu /path2/symlink, then qemu treats
      a relative backing file in the qcow2 metadata as being relative
      to /path2, not /path1/to.  Yes, this means that it is possible
      to create a qcow2 file where the choice of WHICH directory and
      symlink you access its contents from will then determine WHICH
      backing file (if any) you actually find; the results can be
      rather screwy, but we have to match what qemu does.
      
      Libvirt and qemu default to creating absolute backing file
      names, so most users don't hit this.  But at least VDSM uses
      symlinks and relative backing names alongside the
      --reuse-external flags to libvirt snapshot operations, with the
      result that libvirt was failing to follow the intended chain of
      backing files, and then backing files were not granted the
      necessary sVirt permissions to be opened by qemu.
      
      See https://bugzilla.redhat.com/show_bug.cgi?id=903248 for
      more gory details.  This fixes a regression introduced in
      commit 82507838.
      
      I tested this patch by creating the following chain:
      
      ls /home/eblake/Downloads/Fedora.iso # raw file for base
      cd /var/lib/libvirt/images
      qemu-img create -f qcow2 \
        -obacking_file=/home/eblake/Downloads/Fedora.iso,backing_fmt=raw one
      mkdir sub
      cd sub
      ln -s ../one onelink
      qemu-img create -f qcow2 \
        -obacking_file=../sub/onelink,backing_fmt=qcow2 two
      mv two ..
      ln -s ../two twolink
      qemu-img create -f qcow2 \
        -obacking_file=../sub/twolink,backing_fmt=qcow2 three
      mv three ..
      ln -s ../three threelink
      
      then pointing my domain at /var/lib/libvirt/images/sub/threelink.
      Prior to this patch, I got complaints about missing backing
      files; afterwards, I was able to verify that the backing chain
      (and hence DAC and SELinux relabels) of the entire chain worked.
      
      * src/util/virstoragefile.h (_virStorageFileMetadata): Add
      directory member.
      * src/util/virstoragefile.c (absolutePathFromBaseFile): Drop,
      replaced by...
      (virFindBackingFile): ...better function.
      (virStorageFileGetMetadataInternal): Add an argument.
      (virStorageFileGetMetadataFromFD, virStorageFileChainLookup)
      (virStorageFileGetMetadata): Update callers.
      d1333dd0
    • E
      storage: refactor metadata lookup · 2485f921
      Eric Blake 提交于
      Prior to this patch, we had the callchains:
      external users
        \-> virStorageFileGetMetadataFromFD
            \-> virStorageFileGetMetadataFromBuf
      virStorageFileGetMetadataRecurse
        \-> virStorageFileGetMetadataFromFD
            \-> virStorageFileGetMetadataFromBuf
      
      However, a future patch wants to add an additional parameter to
      the bottom of the chain, for use by virStorageFileGetMetadataRecurse,
      without affecting existing external callers.  Since there is only a
      single caller of the internal function, we can repurpose it to fit
      our needs, with this patch giving us:
      
      external users
        \-> virStorageFileGetMetadataFromFD
            \-> virStorageFileGetMetadataInternal
      virStorageFileGetMetadataRecurse /
        \-> virStorageFileGetMetadataInternal
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromFD):
      Move most of the guts...
      (virStorageFileGetMetadataFromBuf): ...here, and rename...
      (virStorageFileGetMetadataInternal): ...to this.
      (virStorageFileGetMetadataRecurse): Use internal helper.
      2485f921
    • E
      storage: prepare for refactoring · b7df4f92
      Eric Blake 提交于
      virStorageFileGetMetadataFromFD is the only caller of
      virStorageFileGetMetadataFromBuf; and it doesn't care about the
      difference between a return of 0 (total success) or 1
      (metadata was inconsistent, but pointer was populated as best
      as possible); only about a return of -1 (could not read metadata
      or out of memory).  Changing the return type, and normalizing
      the variable names used, will make merging the functions easier
      in the next commit.
      
      * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf):
      Change return value, and rename some variables.
      (virStorageFileGetMetadataFromFD): Rename some variables.
      b7df4f92