1. 29 10月, 2011 1 次提交
  2. 15 10月, 2011 2 次提交
    • R
      Add missing strdup return value check · 7c23c34d
      Roopa Prabhu 提交于
      Check strdup return value and fail if error
      Signed-off-by: NRoopa Prabhu <roprabhu@cisco.com>
      7c23c34d
    • O
      qemu: Do not reattach PCI device used by other domain when shutdown · 24b8be89
      Osier Yang 提交于
      When failing on starting a domain, it tries to reattach all the PCI
      devices defined in the domain conf, regardless of whether the devices
      are still used by other domain. This will cause the devices to be deleted
      from the list qemu_driver->activePciHostdevs, thus the devices will be
      thought as usable even if it's not true. And following commands
      nodedev-{reattach,reset} will be successful.
      
      How to reproduce:
        1) Define two domains with same PCI device defined in the confs.
        2) # virsh start domain1
        3) # virsh start domain2
        4) # virsh nodedev-reattach $pci_device
      
      You will see the device will be reattached to host successfully.
      As pciDeviceReattach just check if the device is still used by
      other domain via checking if the device is in list driver->activePciHostdevs,
      however, the device is deleted from the list by step 2).
      
      This patch is to prohibit the bug by:
        1) Prohibit a domain starting or device attachment right at
           preparation period (qemuPrepareHostdevPCIDevices) if the
           device is in list driver->activePciHostdevs, which means
           it's used by other domain.
      
        2) Introduces a new field for struct _pciDevice, (const char *used_by),
           it will be set as the domain name at preparation period,
           (qemuPrepareHostdevPCIDevices). Thus we can prohibit deleting
           the device from driver->activePciHostdevs if it's still used by
           other domain when stopping the domain process.
      
      * src/pci.h (define two internal functions, pciDeviceSetUsedBy and
          pciDevceGetUsedBy)
      * src/pci.c (new field "const char *used_by" for struct _pciDevice,
          implementations for the two new functions)
      * src/libvirt_private.syms (Add the two new internal functions)
      * src/qemu_hostdev.h (Modify the definition of functions
          qemuPrepareHostdevPCIDevices, and qemuDomainReAttachHostdevDevices)
      * src/qemu_hostdev.c (Prohibit preparation and don't delete the
          device from activePciHostdevs list if it's still used by other domain)
      * src/qemu_hotplug.c (Update function usage, as the definitions are
          changed)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      24b8be89
  3. 20 9月, 2011 1 次提交
  4. 17 8月, 2011 1 次提交
  5. 16 8月, 2011 2 次提交
  6. 22 7月, 2011 1 次提交
    • E
      build: rename files.h to virfile.h · 8e22e089
      Eric Blake 提交于
      In preparation for a future patch adding new virFile APIs.
      
      * src/util/files.h, src/util/files.c: Move...
      * src/util/virfile.h, src/util/virfile.c: ...here, and rename
      functions to virFile prefix.  Macro names are intentionally
      left alone.
      * *.c: All '#include "files.h"' uses changed.
      * src/Makefile.am (UTIL_SOURCES): Reflect rename.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_close): Likewise.
      * src/libvirt_private.syms: Likewise.
      * docs/hacking.html.in: Likewise.
      * HACKING: Regenerate.
      8e22e089
  7. 06 7月, 2011 1 次提交
    • G
      pci: initialize state values on reattach · 416814e6
      Guannan Ren 提交于
      add a new API pciDeviceReAttachInit() in pci.c to initialize state values for nodedev reattach
      
      Initialize three state value of device driver to 1. This is just for a new call to
      qemudNodeDeviceReAttach()
      416814e6
  8. 02 7月, 2011 1 次提交
    • E
      pci: avoid memory leak on error · 95eaf7ba
      Eric Blake 提交于
      Detected by Coverity.  Some, but not all, error paths were clean;
      but they were repetitive so I refactored them.
      
      * src/util/pci.c (pciGetDevice): Plug leak.
      95eaf7ba
  9. 23 6月, 2011 1 次提交
    • E
      util: avoid PATH_MAX-sized array · 60bfd5b5
      Eric Blake 提交于
      See previous patch for why this is good...
      
      * src/util/pci.c (struct _pciDevice, pciGetDevice, pciFreeDevice):
      Manage path dynamically.  Report snprintf overflow.
      * src/util/hostusb.c (struct _usbDevice, usbGetDevice)
      (usbFreeDevice): Likewise.
      60bfd5b5
  10. 08 6月, 2011 1 次提交
  11. 01 6月, 2011 1 次提交
    • O
      util: Fix incorrect error in PCI functions · a74575e3
      Osier Yang 提交于
      Substitute VIR_ERR_NO_SUPPORT with VIR_ERR_INTERNAL_ERROR. Error
      like following is not what user want to see.
      
      error : pciDeviceIsAssignable:1487 : this function is not supported
      by the connection driver: Device 0000:07:10.0 is behind a switch
      lacking ACS and cannot be assigned
      a74575e3
  12. 12 5月, 2011 1 次提交
    • L
      libvirt,logging: cleanup VIR_XXX0() · b65f37a4
      Lai Jiangshan 提交于
      These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.
      
      How do these coversions works? The magic is using the gcc extension of ##.
      When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
      avoid compile error.
      
      example: origin				after CPP
      	high_level_api("%d", a_int)	low_level_api("%d", a_int)
      	high_level_api("a  string")	low_level_api("a  string")
      
      About 400 conversions.
      
      8 special conversions:
      VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
      VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
      VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
        (for security) 6 conversions
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      b65f37a4
  13. 04 5月, 2011 1 次提交
    • E
      pci: fix null pointer dereference · 1164e1a2
      Eric Blake 提交于
      Clang detected a null-pointer dereference regression, introduced
      in commit 4e8969eb.  Without this patch, a device with
      unbind_from_stub set to false would eventually try to call
      virFileExists on uncomputed drvdir.
      
      * src/util/pci.c (pciUnbindDeviceFromStub): Ensure drvdir is set
      before use.
      1164e1a2
  14. 17 4月, 2011 1 次提交
  15. 12 4月, 2011 1 次提交
    • E
      maint: fix grammar errors · 99fa3080
      Eric Blake 提交于
      Jim Meyering recently improved gnulib to catch various grammar
      errors during 'make syntax-check'.
      
      * .gnulib: Update to latest, for syntax-check improvements.
      * include/libvirt/libvirt.h.in (virConnectAuthCallbackPtr): Use
      cannot rather than two words.
      * src/driver.c: Likewise.
      * src/driver.h (VIR_SECRET_GET_VALUE_INTERNAL_CALL): Likewise.
      * src/remote/remote_driver.c (initialize_gnutls): Likewise.
      * src/util/pci.c (pciBindDeviceToStub): Likewise.
      * src/storage/storage_backend.c (virStorageBackendCreateQemuImg):
      Likewise.
      (virStorageBackendUpdateVolTargetInfoFD): Avoid doubled word.
      * docs/formatdomain.html.in: Likewise.
      * src/qemu/qemu_process.c (qemuProcessStart): Likewise.
      * cfg.mk (exclude_file_name_regexp--sc_prohibit_can_not)
      (exclude_file_name_regexp--sc_prohibit_doubled_word): Exclude
      existing translation problems.
      99fa3080
  16. 07 4月, 2011 3 次提交
  17. 05 4月, 2011 1 次提交
  18. 18 3月, 2011 1 次提交
  19. 03 12月, 2010 1 次提交
    • J
      Create file in virFileWriteStr() if it doesn't exist · 966a1bfe
      Jean-Baptiste Rouault 提交于
      This patch adds a mode_t parameter to virFileWriteStr().
      If mode is different from 0, virFileWriteStr() will try
      to create the file if it doesn't exist.
      
      * src/util/util.h (virFileWriteStr): Alter signature.
      * src/util/util.c (virFileWriteStr): Allow file creation.
      * src/network/bridge_driver.c (networkEnableIpForwarding)
      (networkDisableIPV6): Adjust clients.
      * src/node_device/node_device_driver.c
      (nodeDeviceVportCreateDelete): Likewise.
      * src/util/cgroup.c (virCgroupSetValueStr): Likewise.
      * src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
      Likewise.
      966a1bfe
  20. 25 11月, 2010 1 次提交
    • E
      build: enforce files.h usage · f1fe9671
      Eric Blake 提交于
      * cfg.mk (sc_prohibit_close): New syntax-check rule.
      * src/util/pci.c (pciWaitForDeviceCleanup): Fix violation.
      * .x-sc_prohibit_close: New exceptions.
      * Makefile.am (EXTRA_DIST): Distribute new file.
      f1fe9671
  21. 10 11月, 2010 1 次提交
    • S
      bye to close(), welcome to VIR_(FORCE_)CLOSE() · 60ae1c34
      Stefan Berger 提交于
      Using automated replacement with sed and editing I have now replaced all
      occurrences of close() with VIR_(FORCE_)CLOSE() except for one, of
      course. Some replacements were straight forward, others I needed to pay
      attention. I hope I payed attention in all the right places... Please
      have a look. This should have at least solved one more double-close
      error.
      60ae1c34
  22. 23 9月, 2010 1 次提交
  23. 02 8月, 2010 1 次提交
    • C
      Fix the ACS checking in the PCI code. · 86b043ad
      Chris Lalancette 提交于
      When trying to assign a PCI device to a guest, we have
      to check that all bridges upstream of that device support
      ACS.  That means that we have to find the parent bridge of
      the current device, check for ACS, then find the parent bridge
      of that device, check for ACS, etc.  As it currently stands,
      the code to do this iterates through all PCI devices on the
      system, looking for a device that has a range of busses that
      included the current device's bus.
      
      That check is not restrictive enough, though.  Depending on
      how we iterated through the list of PCI devices, we could first
      find the *topmost* bridge in the system; since it necessarily had
      a range of busses including the current device's bus, we
      would only ever check the topmost bridge, and not check
      any of the intermediate bridges.
      
      Note that this also caused a fairly serious bug in the
      secondary bus reset code, where we could erroneously
      find and reset the topmost bus instead of the inner bus.
      
      This patch changes pciGetParentDevice() so that it first
      checks if a bridge device's secondary bus exactly matches
      the bus of the device we are looking for.  If it does, we've
      found the correct parent bridge and we are done.  If it does not,
      then we check to see if this bridge device's busses *include* the
      bus of the device we care about.  If so, we mark this bridge device
      as best, and go on.  If we later find another bridge device whose
      busses include this device, but is more restrictive, then we
      free up the previous best and mark the new one as best.  This
      algorithm ensures that in the normal case we find the direct
      parent, but in the case that the parent bridge secondary bus
      is not exactly the same as the device, we still find the
      correct bridge.
      
      This patch was tested by me on a 4-port NIC with a
      bridge without ACS (where assignment failed), a 4-port
      NIC with a bridge with ACS (where assignment succeeded),
      and a 2-port NIC with no bridges (where assignment
      succeeded).
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      86b043ad
  24. 29 7月, 2010 1 次提交
    • C
      Fix a potential race in pciInitDevice. · 56b40823
      Chris Lalancette 提交于
      If detecting the FLR flag of a pci device fails, then we
      could run into the situation of trying to close a file
      descriptor twice, once in pciInitDevice() and once in pciFreeDevice().
      Fix that by removing the pciCloseConfig() in pciInitDevice() and
      just letting pciFreeDevice() handle it.
      
      Thanks to Chris Wright for pointing out this problem.
      
      While we are at it, fix an error check.  While it would actually
      work as-is (since success returns 0), it's still more clear to
      check for < 0 (as the rest of the code does).
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      56b40823
  25. 27 7月, 2010 2 次提交
    • C
      Force FLR on for buggy SR-IOV devices. · 71e92a15
      Chris Lalancette 提交于
      Some buggy PCI devices actually support FLR, but
      forget to advertise that fact in their PCI config space.
      However, Virtual Functions on SR-IOV devices are
      *required* to support FLR by the spec, so force has_flr
      on if this is a virtual function.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      71e92a15
    • C
      pciResetDevice: use inactive devices to determine safe reset · 46bcdb96
      Chris Wright 提交于
      When doing a PCI secondary bus reset, we must be sure that there are no
      active devices on the same bus segment.  The active device tracking is
      designed to only track host devices that are active in use by guests.
      This ignores host devices that are actively in use by the host.  So the
      current logic will reset host devices.
      
      Switch this logic around and allow sbus reset when we are assigning all
      devices behind a bridge to the same guest at guest startup or as a result
      of a single attach-device command.
      
      * src/util/pci.h: change signature of pciResetDevice to add an
        inactive devices list
      * src/qemu/qemu_driver.c src/xen/xen_driver.c: use (or not) the new
        functionality of pciResetDevice() depending on the place of use
      * src/util/pci.c: implement the interface and logic changes
      46bcdb96
  26. 23 7月, 2010 1 次提交
    • C
      pciSharesBusWithActive fails to find multiple devices on bus · f4828ca3
      Chris Wright 提交于
      The first conditional is always true which means the iterator will
      never find another device on the same bus.
      
          if (dev->domain != check->domain ||
              dev->bus != check->bus ||
        ----> (check->slot == check->slot &&
               check->function == check->function)) <-----
      
      The goal of that check is to verify that the device is either:
      
        in a different pci domain
        on a different bus
        is the same identical device
      
      This means libvirt may issue a secondary bus reset when there are
      devices
      on that bus that actively in use by the host or another guest.
      
      * src/util/pci.c: fix a bogus test in pciSharesBusWithActive()
      f4828ca3
  27. 29 6月, 2010 1 次提交
    • C
      Check for active PCI devices when doing nodedevice operations. · 53a1db4d
      Chris Lalancette 提交于
      In the current libvirt PCI code, there is no checking whether
      a PCI device is in use by a guest when doing node device
      detach or reattach.  This causes problems when a device is
      assigned to a guest, and the administrator starts issuing
      nodedevice commands.  Make it so that we check the list
      of active devices when trying to detach/reattach, and only
      allow the operation if the device is not assigned to a guest.
      Signed-off-by: NChris Lalancette <clalance@redhat.com>
      53a1db4d
  28. 19 5月, 2010 1 次提交
  29. 18 5月, 2010 1 次提交
  30. 01 4月, 2010 1 次提交
    • M
      Replace sscanf in PCI device address parsing · d13eb9fc
      Matthias Bolte 提交于
      This also fixes a problem with MinGW's GCC on Windows. GCC complains
      about the L modifier being unknown.
      
      Parsing in pciIterDevices is stricter now and doesn't accept trailing
      characters after the actual <domain>:<bus>:<slot>.<function> sequence
      anymore.
      
      Parsing in pciWaitForDeviceCleanup is also stricter now and expects
      the <start>-<end> : <domain>:<bus>:<slot>.<function> sequence to be
      terminated by \n.
      
      Change domain from unsigned long long to unsigned int in
      pciWaitForDeviceCleanup, because everywhere else domain is handled as
      unsigned int too.
      d13eb9fc
  31. 10 3月, 2010 1 次提交
  32. 08 3月, 2010 1 次提交
    • E
      build: consistently use C99 varargs macros · 2e56fb2b
      Eric Blake 提交于
      Prior to this patch, there was an inconsistent mix between GNU and C99.
      
      For consistency, and potential portability to other compilers, stick
      with the C99 vararg macro syntax.
      
      * src/conf/cpu_conf.c (virCPUReportError): Use C99 rather than GNU
        vararg macro syntax.
      * src/conf/domain_conf.c (virDomainReportError): Likewise.
      * src/conf/domain_event.c (eventReportError): Likewise.
      * src/conf/interface_conf.c (virInterfaceReportError): Likewise.
      * src/conf/network_conf.c (virNetworkReportError): Likewise.
      * src/conf/node_device_conf.h (virNodeDeviceReportError): Likewise.
      * src/conf/secret_conf.h (virSecretReportError): Likewise.
      * src/conf/storage_conf.h (virStorageReportError): Likewise.
      * src/esx/esx_device_monitor.c (ESX_ERROR): Use C99 rather than
        GNU vararg macro syntax.
      * src/esx/esx_driver.c (ESX_ERROR): Likewise.
      * src/esx/esx_interface_driver.c (ESX_ERROR): Likewise.
      * src/esx/esx_network_driver.c (ESX_ERROR): Likewise.
      * src/esx/esx_secret_driver.c (ESX_ERROR): Likewise.
      * src/esx/esx_storage_driver.c (ESX_ERROR): Likewise.
      * src/esx/esx_util.c (ESX_ERROR): Likewise.
      * src/esx/esx_vi.c (ESX_VI_ERROR): Likewise.
      * src/esx/esx_vi_methods.c (ESX_VI_ERROR): Likewise.
      * src/esx/esx_vi_types.c (ESX_VI_ERROR): Likewise.
      * src/esx/esx_vmx.c (ESX_ERROR): Likewise.
      * src/util/hostusb.c (usbReportError): Use C99 rather than GNU
        vararg macro syntax.
      * src/util/json.c (virJSONError): Likewise.
      * src/util/macvtap.c (ReportError): Likewise.
      * src/util/pci.c (pciReportError): Likewise.
      * src/util/stats_linux.c (virStatsError): Likewise.
      * src/util/util.c (virUtilError): Likewise.
      * src/util/xml.c (virXMLError): Likewise.
      * src/xen/proxy_internal.c (virProxyError): Use C99 rather than
        GNU vararg macro syntax.
      * src/xen/sexpr.c (virSexprError): Likewise.
      * src/xen/xen_driver.c (xenUnifiedError): Likewise.
      * src/xen/xen_hypervisor.c (virXenError): Likewise.
      * src/xen/xen_inotify.c (virXenInotifyError): Likewise.
      * src/xen/xend_internal.c (virXendError): Likewise.
      * src/xen/xm_internal.c (xenXMError): Likewise.
      * src/xen/xs_internal.c (virXenStoreError): Likewise.
      * src/cpu/cpu.h (virCPUReportError): Use C99 rather than GNU
        vararg macro syntax.
      * src/datatypes.c (virLibConnError): Likewise.
      * src/interface/netcf_driver.c (interfaceReportError): Likewise.
      * src/libvirt.c (virLibStreamError): Likewise.
      * src/lxc/lxc_conf.h (lxcError): Likewise.
      * src/network/bridge_driver.c (networkReportError): Likewise.
      * src/nodeinfo.c (nodeReportError): Likewise.
      * src/opennebula/one_conf.h (oneError): Likewise.
      * src/openvz/openvz_conf.h (openvzError): Likewise.
      * src/phyp/phyp_driver.c (PHYP_ERROR): Likewise.
      * src/qemu/qemu_conf.h (qemuReportError): Likewise.
      * src/remote/remote_driver.c (errorf): Likewise.
      * src/security/security_driver.h (virSecurityReportError): Likewise.
      * src/test/test_driver.c (testError): Likewise.
      * src/uml/uml_conf.h (umlReportError): Likewise.
      * src/vbox/vbox_driver.c (vboxError): Likewise.
      * src/vbox/vbox_tmpl.c (vboxError): Likewise.
      2e56fb2b
  33. 19 2月, 2010 1 次提交
  34. 10 2月, 2010 1 次提交
    • D
      Remove virConnectPtr from USB/PCI device iterators · ce71b865
      Daniel P. Berrange 提交于
      All callers now pass a NULL virConnectPtr into the USB/PCi device
      iterator functions. Therefore the virConnectPtr arg can now be
      removed from these functions
      
      * src/util/hostusb.h, src/util/hostusb.c: Remove virConnectPtr
        from usbDeviceFileIterate
      * src/util/pci.c, src/util/pci.h: Remove virConnectPtr arg from
        pciDeviceFileIterate
      * src/qemu/qemu_security_dac.c, src/security/security_selinux.c: Update
        to drop redundant virConnectPtr arg
      ce71b865
  35. 09 2月, 2010 1 次提交