1. 20 3月, 2012 1 次提交
    • L
      conf: forbid use of multicast mac addresses · 00072373
      Laine Stump 提交于
      A few times libvirt users manually setting mac addresses have
      complained of a networking failure that ends up being due to a multicast
      mac address being used for a guest interface. This patch prevents that
      by logging an error and failing if a multicast mac address is
      encountered in each of the three following cases:
      
      1) domain xml <interface> mac address.
      2) network xml bridge mac address.
      3) network xml dhcp/host mac address.
      
      There are several other places where a mac address can be input that
      aren't controlled in this manner because failure to do so has no
      consequences (e.g., if the address will be used to search through
      existing interfaces for a match).
      
      The RNG has been updated to add multiMacAddr and uniMacAddr along with
      the existing macAddr, and macAddr was switched to uniMacAddr where
      appropriate.
      00072373
  2. 15 3月, 2012 2 次提交
    • O
      numad: Fix typo and warning · d86120fc
      Osier Yang 提交于
      src/libvirt_private.syms:
        s/virDomainCpuPlacement/virDomainCpuPlacementMode/
      src/qemu/qemu_process.c
        def->mem.cur_balloon expects "llu"
      --
      pushed under build-breaker rule
      d86120fc
    • O
      qemu: Support numad · 0f8e7ae3
      Osier Yang 提交于
      numad is an user-level daemon that monitors NUMA topology and
      processes resource consumption to facilitate good NUMA resource
      alignment of applications/virtual machines to improve performance
      and minimize cost of remote memory latencies. It provides a
      pre-placement advisory interface, so significant processes can
      be pre-bound to nodes with sufficient available resources.
      
      More details: http://fedoraproject.org/wiki/Features/numad
      
      "numad -w ncpus:memory_amount" is the advisory interface numad
      provides currently.
      
      This patch add the support by introducing a new XML attribute
      for <vcpu>. e.g.
      
        <vcpu placement="auto">4</vcpu>
        <vcpu placement="static" cpuset="1-10^6">4</vcpu>
      
      The returned advisory nodeset from numad will be printed
      in domain's dumped XML. e.g.
        <vcpu placement="auto" cpuset="1-10^6">4</vcpu>
      
      If placement is "auto", the number of vcpus and the current
      memory amount specified in domain XML will be used for numad
      command line (numad uses MB for memory amount):
        numad -w $num_of_vcpus:$current_memory_amount / 1024
      
      The advisory nodeset returned from numad will be used to set
      domain process CPU affinity then. (e.g. qemuProcessInitCpuAffinity).
      
      If the user specifies both CPU affinity policy (e.g.
      (<vcpu cpuset="1-10,^7,^8">4</vcpu>) and placement == "auto"
      the specified CPU affinity will be overridden.
      
      Only QEMU/KVM drivers support it now.
      
      See docs update in patch for more details.
      0f8e7ae3
  3. 12 3月, 2012 1 次提交
    • E
      cpustats: collect VM user and sys times · 0d0b4098
      Eric Blake 提交于
      As documented in linux.git/Documentation/cgroups/cpuacct.txt,
      cpuacct.stat returns user and system time in ticks (the same
      unit used in times(2)).  It would be a bit nicer if it were like
      getrusage(2) and reported timeval contents, or like cpuacct.usage
      and in nanoseconds, but we can't be picky.
      
      * src/util/cgroup.h (virCgroupGetCpuacctStat): New function.
      * src/util/cgroup.c (virCgroupGetCpuacctStat): Implement it.
      (virCgroupGetValueStr): Allow for multi-line files.
      * src/libvirt_private.syms (cgroup.h): Export it.
      0d0b4098
  4. 09 3月, 2012 2 次提交
  5. 08 3月, 2012 2 次提交
    • M
      qemu: Don't parse device twice in attach/detach · 1e0534a7
      Michal Privoznik 提交于
      Some members are generated during XML parse (e.g. MAC address of
      an interface); However, with current implementation, if we
      are plugging a device both to persistent and live config,
      we parse given XML twice: first time for live, second for config.
      This is wrong then as the second time we are not guaranteed
      to generate same values as we did for the first time.
      To prevent that we need to create a copy of DeviceDefPtr;
      This is done through format/parse process instead of writing
      functions for deep copy as it is easier to maintain:
      adding new field to any virDomain*DefPtr doesn't require change
      of copying function.
      1e0534a7
    • E
      util: new function for scaling numbers · 0d90823e
      Eric Blake 提交于
      Scaling an integer based on a suffix is something we plan on reusing
      in several contexts: XML parsing, virsh CLI parsing, and possibly
      elsewhere.  Make it easy to reuse, as well as adding in support for
      powers of 1000.
      
      * src/util/util.h (virScaleInteger): New function.
      * src/util/util.c (virScaleInteger): Implement it.
      * src/libvirt_private.syms (util.h): Export it.
      0d90823e
  6. 07 3月, 2012 2 次提交
  7. 06 3月, 2012 7 次提交
    • R
      qemu: install port profile and mac address on netdev hostdevs · ce43483c
      Roopa Prabhu 提交于
      These changes are applied only if the hostdev has a parent net device
      (i.e. if it was defined as "<interface type='hostdev'>" rather than
      just "<hostdev>").  If the parent netdevice has virtual port
      information, the original virtualport associate functions are called
      (these set and restore both mac and port profile on an
      interface). Otherwise, only mac address is set on the device.
      
      Note that This is only supported for SR-IOV Virtual Functions (not for
      standard PCI or USB netdevs), and virtualport association is only
      supported for 802.1Qbh. For all other types of cards and types of
      virtualport, a "Config Unsupported" error is returned and the
      operation fails.
      Signed-off-by: NRoopa Prabhu <roprabhu@cisco.com>
      ce43483c
    • R
      util: support functions for mac/portprofile associations on hostdev · 5095bf06
      Roopa Prabhu 提交于
      This patch adds the following:
      
      - functions to set and get vf configs
      - Functions to replace and store vf configs (Only mac address is handled today.
        But the functions can be easily extended for vlans and other vf configs)
      - function to dump link dev info (This is moved from virnetdevvportprofile.c)
      Signed-off-by: NRoopa Prabhu <roprabhu@cisco.com>
      5095bf06
    • R
      util: two new pci util functions · b8b70273
      Roopa Prabhu 提交于
      pciDeviceGetVirtualFunctionInfo returns pf netdevice name and virtual
      function index for a given vf. This is just a wrapper around existing functions
      to return vf's pf and vf_index with one api call
      
      pciConfigAddressToSysfsfile returns the sysfile pci device link
      from a 'struct pci_config_address'
      Signed-off-by: NRoopa Prabhu <roprabhu@cisco.com>
      b8b70273
    • L
      conf: change virDomainNetRemove from static to global · ac9ca01c
      Laine Stump 提交于
      This exact code is duplicated in qemuDomainDetachNetDevice().
      ac9ca01c
    • L
      conf: parse/format type='hostdev' network interfaces · 3b1c191f
      Laine Stump 提交于
      This is the new interface type that sets up an SR-IOV PCI network
      device to be assigned to the guest with PCI passthrough after
      initializing some network device-specific things from the config
      (e.g. MAC address, virtualport profile parameters). Here is an example
      of the syntax:
      
        <interface type='hostdev' managed='yes'>
          <source>
            <address type='pci' domain='0' bus='0' slot='4' function='3'/>
          </source>
          <mac address='00:11:22:33:44:55'/>
          <address type='pci' domain='0' bus='0' slot='7' function='0'/>
        </interface>
      
      This would assign the PCI card from bus 0 slot 4 function 3 on the
      host, to bus 0 slot 7 function 0 on the guest, but would first set the
      MAC address of the card to 00:11:22:33:44:55.
      
      NB: The parser and formatter don't care if the PCI card being
      specified is a standard single function network adapter, or a virtual
      function (VF) of an SR-IOV capable network adapter, but the upcoming
      code that implements the back end of this config will work *only* with
      SR-IOV VFs. This is because modifying the mac address of a standard
      network adapter prior to assigning it to a guest is pointless - part
      of the device reset that occurs during that process will reset the MAC
      address to the value programmed into the card's firmware.
      
      Although it's not supported by any of libvirt's hypervisor drivers,
      usb network hostdevs are also supported in the parser and formatter
      for completeness and consistency. <source> syntax is identical to that
      for plain <hostdev> devices, except that the <address> element should
      have "type='usb'" added if bus/device are specified:
      
        <interface type='hostdev'>
          <source>
            <address type='usb' bus='0' device='4'/>
          </source>
          <mac address='00:11:22:33:44:55'/>
        </interface>
      
      If the vendor/product form of usb specification is used, type='usb'
      is implied:
      
        <interface type='hostdev'>
          <source>
            <vendor id='0x0012'/>
            <product id='0x24dd'/>
          </source>
          <mac address='00:11:22:33:44:55'/>
        </interface>
      
      Again, the upcoming patch to fill in the backend of this functionality
      will log an error and fail with "Unsupported Config" if you actually
      try to assign a USB network adapter to a guest using <interface
      type='hostdev'> - just use a standard <hostdev> entry in that case
      (and also for single-port PCI adapters).
      3b1c191f
    • L
      conf: hostdev utility functions · cc5b1fe5
      Laine Stump 提交于
      Three new functions useful in other files:
      
      virDomainHostdevInsert:
      
      Add a new hostdev at the end of the array. This would more sensibly be
      called virDomainHostdevAppend, but the existing functions for other
      types of devices are called Insert.
      
      virDomainHostdevRemove:
      
      Eliminates one entry from the hostdevs array, but doesn't free it;
      patterned after the code at the end of the two
      qemuDomainDetachHostXXXDevice functions (and also other pre-existing
      virDomainXXXRemove functions for other device types).
      
      virDomainHostdevFind:
      
      This function is patterned from the search loops at the top of
      qemuDomainDetachHostPciDevice and qemuDomainDetachHostUsbDevice, and
      will be used to re-factor those (and other detach-related) functions.
      cc5b1fe5
    • L
      conf: make hostdev info a separate object · 29293930
      Laine Stump 提交于
      In order to allow for a virDomainHostdevDef that uses the
      virDomainDeviceInfo of a "higher level" device (such as a
      virDomainNetDef), this patch changes the virDomainDeviceInfo in the
      HostdevDef into a virDomainDeviceInfoPtr. Rather than adding checks
      all over the code to check for a null info, we just guarantee that it
      is always valid. The new function virDomainHostdevDefAlloc() allocates
      a virDomainDeviceInfo and plugs it in, and virDomainHostdevDefFree()
      makes sure it is freed.
      
      There were 4 places allocating virDomainHostdevDefs, all of them
      parsers of one sort or another, and those have all had their
      VIR_ALLOC(hostdev) changed to virDomainHostdevDefAlloc(). Other than
      that, and the new functions, all the rest of the changes are just
      mechanical removals of "&" or changing "." to "->".
      29293930
  8. 01 3月, 2012 1 次提交
  9. 29 2月, 2012 1 次提交
  10. 28 2月, 2012 1 次提交
  11. 27 2月, 2012 1 次提交
    • P
      util: Add helpers for safe domain console operations · 3f4238d7
      Peter Krempa 提交于
      This patch adds a set of functions used in creating console streams for
      domains using PTYs and ensures mutually exclusive access to the PTYs.
      
      If mutually exclusive access is not used, two clients may open the same
      console, which results in corruption on both clients as both of them
      race to read data from the PTY.
      
      Two approaches are used to ensure this:
      1) Internal data structure holding open PTYs.
              This is used internally and enables the user to forcibly
              terminate another console connection eg. when somebody leaves
              the console open on another host.
      
      2) UUCP style lock files:
              This uses UUCP lock files according to the  FHS
              ( http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLOCKLOCKFILES )
              to check if other programs (like minicom) are not using the pty
              device of the console.
      
              This feature is disabled by default and may be enabled using
              configure parameter
              --with-console-lock-files=/path/to/lock/file/directory
              or --with-console-lock-files=auto (which tries to infer the
              location from OS used (currently only linux).
      
              On usual linux systems, normal users may not write to the
              /var/lock directory containing the locks. This poses problems
              while in session mode. If the current user has no access to the
              lockfile directory, check for presence of the file is still
              done, but no lock file is created. This does NOT result in an
              error.
      3f4238d7
  12. 25 2月, 2012 1 次提交
    • M
      Fixed URI parsing · 9f748277
      Martin Kletzander 提交于
      Function xmlParseURI does not remove square brackets around IPv6
      address when parsing. One of the solutions is making wrappers around
      functions working with xmlURI*. This assures that uri->server will be
      always properly assigned and it doesn't have to be changed when used
      on some new place in the code.
      For this purpose, functions virParseURI and virSaveURI were
      added. These function are wrappers around xmlParseURI and xmlSaveUri
      respectively.
      Also there is one new syntax check function to prohibit these functions
      anywhere else.
      
      File changes:
       - src/util/viruri.h        -- declaration
       - src/util/viruri.c        -- definition
       - src/libvirt_private.syms -- symbol export
       - src/Makefile.am          -- added source and header files
       - cfg.mk                   -- added sc_prohibit_xmlURI
       - all others               -- ID name and include fixes
      9f748277
  13. 23 2月, 2012 1 次提交
  14. 16 2月, 2012 2 次提交
    • A
      network: support Open vSwitch · df810046
      Ansis Atteka 提交于
      This patch allows libvirt to add interfaces to already
      existing Open vSwitch bridges. The following syntax in
      domain XML file can be used:
      
          <interface type='bridge'>
            <mac address='52:54:00:d0:3f:f2'/>
            <source bridge='ovsbr'/>
            <virtualport type='openvswitch'>
              <parameters interfaceid='921a80cd-e6de-5a2e-db9c-ab27f15a6e1d'/>
            </virtualport>
            <address type='pci' domain='0x0000' bus='0x00'
                                slot='0x03' function='0x0'/>
          </interface>
      
      or if libvirt should auto-generate the interfaceid use
      following syntax:
      
          <interface type='bridge'>
            <mac address='52:54:00:d0:3f:f2'/>
            <source bridge='ovsbr'/>
            <virtualport type='openvswitch'>
            </virtualport>
            <address type='pci' domain='0x0000' bus='0x00'
                                slot='0x03' function='0x0'/>
          </interface>
      
      It is also possible to pass an optional profileid. To do that
      use following syntax:
      
         <interface type='bridge'>
           <source bridge='ovsbr'/>
           <mac address='00:55:1a:65:a2:8d'/>
           <virtualport type='openvswitch'>
             <parameters interfaceid='921a80cd-e6de-5a2e-db9c-ab27f15a6e1d'
                         profileid='test-profile'/>
           </virtualport>
         </interface>
      
      To create Open vSwitch bridge install Open vSwitch and
      run the following command:
      
          ovs-vsctl add-br ovsbr
      df810046
    • L
      conf: rename virDomainNetGetActualDirectVirtPortProfile · 9368465f
      Laine Stump 提交于
      An upcoming patch will add a <virtualport> element to interfaces of
      type='bridge', so it makes sense to give this function a more generic
      name.
      9368465f
  15. 10 2月, 2012 1 次提交
    • O
      npiv: Auto-generate WWN if it's not specified · 7c90026d
      Osier Yang 提交于
      The auto-generated WWN comply with the new addressing schema of WWN:
      
      <quote>
      the first nibble is either hex 5 or 6 followed by a 3-byte vendor
      identifier and 36 bits for a vendor-specified serial number.
      </quote>
      
      We choose hex 5 for the first nibble. And for the 3-bytes vendor ID,
      we uses the OUI according to underlying hypervisor type, (invoking
      virConnectGetType to get the virt type). e.g. If virConnectGetType
      returns "QEMU", we use Qumranet's OUI (00:1A:4A), if returns
      ESX|VMWARE, we use VMWARE's OUI (00:05:69). Currently it only
      supports qemu|xen|libxl|xenapi|hyperv|esx|vmware drivers. The last
      36 bits are auto-generated.
      7c90026d
  16. 09 2月, 2012 1 次提交
  17. 04 2月, 2012 1 次提交
  18. 02 2月, 2012 2 次提交
  19. 28 1月, 2012 3 次提交
  20. 27 1月, 2012 1 次提交
    • S
      nwfilter: Force instantiation of filters upon driver reload · 8fa78dd4
      Stefan Berger 提交于
      Introduce a function that rebuilds all running VMs' filters. Call
      this function when reloading the nwfilter driver.
      
      This addresses a problem introduced by the 2nd patch that typically
      causes no filters to be reinstantiate anymore upon driver reload
      since their XML has not changed. Yet the current behavior is that
      upon a SIGHUP all filters get reinstantiated.
      8fa78dd4
  21. 26 1月, 2012 1 次提交
    • D
      Introduce new API for generating random numbers · e95ef67b
      Daniel P. Berrange 提交于
      The old virRandom() API was not generating good random numbers.
      Replace it with a new API virRandomBits which instead of being
      told the upper limit, gets told the number of bits of randomness
      required.
      
      * src/util/virrandom.c, src/util/virrandom.h: Add virRandomBits,
        and move virRandomInitialize
      * src/util/util.h, src/util/util.c: Delete virRandom and
        virRandomInitialize
      * src/libvirt.c, src/security/security_selinux.c,
        src/test/test_driver.c, src/util/iohelper.c: Update for
        changes from virRandom to virRandomBits
      * src/storage/storage_backend_iscsi.c: Remove bogus call
        to virRandomInitialize & convert to virRandomBits
      e95ef67b
  22. 25 1月, 2012 1 次提交
  23. 20 1月, 2012 2 次提交
    • E
      error: drop old-style error reporting · c2551bea
      Eric Blake 提交于
      While we still don't want to enable gcc's new -Wformat-literal
      warning, I found a rather easy case where the warning could be
      reduced, by getting rid of obsolete error-reporting practices.
      This is the last place where we were passing the (unused) net
      and conn arguments for constructing an error.
      
      * src/util/virterror_internal.h (virErrorMsg): Delete prototype.
      (virReportError): Delete macro.
      * src/util/virterror.c (virErrorMsg): Make static.
      * src/libvirt_private.syms (virterror_internal.h): Drop export.
      * src/util/conf.c (virConfError): Convert to macro.
      (virConfErrorHelper): New function, and adjust error calls.
      * src/xen/xen_hypervisor.c (virXenErrorFunc): Delete.
      (xenHypervisorGetSchedulerType)
      (xenHypervisorGetSchedulerParameters)
      (xenHypervisorSetSchedulerParameters)
      (xenHypervisorDomainBlockStats)
      (xenHypervisorDomainInterfaceStats)
      (xenHypervisorDomainGetOSType)
      (xenHypervisorNodeGetCellsFreeMemory, xenHypervisorGetVcpus):
      Update callers.
      c2551bea
    • E
      util: add new file for virTypedParameter utils · 61ca98b0
      Eric Blake 提交于
      Preparation for another patch that refactors common patterns
      into the new file for fewer lines of code overall.
      
      * src/util/util.h (virTypedParameterArrayClear): Move...
      * src/util/virtypedparam.h: ...to new file.
      (virTypedParameterArrayValidate, virTypedParameterAssign): New
      prototypes.
      * src/util/util.c (virTypedParameterArrayClear): Likewise.
      * src/util/virtypedparam.c: New file.
      * po/POTFILES.in: Mark file for translation.
      * src/Makefile.am (UTIL_SOURCES): Build it.
      * src/libvirt_private.syms (util.h): Split...
      (virtypedparam.h): to new section.
      (virkeycode.h): Sort.
      * daemon/remote.c: Adjust callers.
      * tools/virsh.c: Likewise.
      61ca98b0
  24. 19 1月, 2012 2 次提交