1. 20 4月, 2012 1 次提交
    • E
      conf: tighten up XML integer parsing · c09acad3
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=617711 reported that
      even with my recent patched to allow <memory unit='G'>1</memory>,
      people can still get away with trying <memory>1G</memory> and
      silently get <memory unit='KiB'>1</memory> instead.  While
      virt-xml-validate catches the error, our C parser did not.
      
      Not to mention that it's always fun to fix bugs while reducing
      lines of code.  :)
      
      * src/conf/domain_conf.c (virDomainParseMemory): Check for parse error.
      (virDomainDefParseXML): Avoid strtoll.
      * src/conf/storage_conf.c (virStorageDefParsePerms): Likewise.
      * src/util/xml.c (virXPathLongBase, virXPathULongBase)
      (virXPathULongLong, virXPathLongLong): Likewise.
      c09acad3
  2. 19 4月, 2012 1 次提交
    • S
      nwfilter: Fix support for trusted DHCP servers · 7c26343b
      Stefan Berger 提交于
      Fix the support for trusted DHCP server in the ebtables code's
      hard-coded function applying DHCP only filtering rules:
      Rather than using a char * use the more flexible
      virNWFilterVarValuePtr that contains the trusted DHCP server(s)
      IP address. Process all entries.
      
      Since all callers so far provided NULL as parameter, no changes
      are necessary in any other code.
      7c26343b
  3. 18 4月, 2012 1 次提交
    • S
      Fix a memory leak · 25fce290
      Stefan Berger 提交于
      The below patch fixes the following memory leak.
      
      ==20624== 24 bytes in 2 blocks are definitely lost in loss record 532 of 1,867
      ==20624==    at 0x4A05E46: malloc (vg_replace_malloc.c:195)
      ==20624==    by 0x38EC27FC01: strdup (strdup.c:43)
      ==20624==    by 0x4EB6BA3: virDomainChrSourceDefCopy (domain_conf.c:1122)
      ==20624==    by 0x495D76: qemuProcessFindCharDevicePTYs (qemu_process.c:1497)
      ==20624==    by 0x498321: qemuProcessWaitForMonitor (qemu_process.c:1258)
      ==20624==    by 0x49B5F9: qemuProcessStart (qemu_process.c:3652)
      ==20624==    by 0x468B5C: qemuDomainObjStart (qemu_driver.c:4753)
      ==20624==    by 0x469171: qemuDomainStartWithFlags (qemu_driver.c:4810)
      ==20624==    by 0x4F21735: virDomainCreate (libvirt.c:8153)
      ==20624==    by 0x4302BF: remoteDispatchDomainCreateHelper (remote_dispatch.h:852)
      ==20624==    by 0x4F72C14: virNetServerProgramDispatch (virnetserverprogram.c:416)
      ==20624==    by 0x4F6D690: virNetServerHandleJob (virnetserver.c:164)
      ==20624==    by 0x4E8F43D: virThreadPoolWorker (threadpool.c:144)
      ==20624==    by 0x4E8EAB5: virThreadHelper (threads-pthread.c:161)
      ==20624==    by 0x38EC606CCA: start_thread (pthread_create.c:301)
      ==20624==    by 0x38EC2E0C2C: clone (clone.S:115) 
      25fce290
  4. 17 4月, 2012 1 次提交
  5. 16 4月, 2012 1 次提交
    • O
      numad: Ignore cpuset if placement is auto · 8fb2164c
      Osier Yang 提交于
      As explained in previous patch, numad will balance the affinity
      dynamically, so reflecting the cpuset from numad at the first
      time doesn't make much case, and may just could cause confusion.
      8fb2164c
  6. 13 4月, 2012 1 次提交
  7. 05 4月, 2012 1 次提交
    • A
      conf: Plug memory leaks on virDomainDiskDefParseXML · 80d476a9
      Alex Jia 提交于
      Detected by valgrind. Leaks are introduced in commit b22eaa75.
      
      * src/conf/domain_conf.c (virDomainDiskDefParseXML): fix memory leaks.
      
      How to reproduce?
      
      % make && make -C tests check TESTS=qemuxml2argvtest
      % cd tests && valgrind -v --leak-check=full ./qemuxml2argvtest
      
      actual result:
      
      ==2143== 12 bytes in 2 blocks are definitely lost in loss record 74 of 179
      ==2143==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
      ==2143==    by 0x39D90A67DD: xmlStrndup (xmlstring.c:45)
      ==2143==    by 0x4F5EC0: virDomainDiskDefParseXML (domain_conf.c:3438)
      ==2143==    by 0x502F00: virDomainDefParseXML (domain_conf.c:8304)
      ==2143==    by 0x505FE3: virDomainDefParseNode (domain_conf.c:9080)
      ==2143==    by 0x5069AE: virDomainDefParse (domain_conf.c:9030)
      ==2143==    by 0x41CBF4: testCompareXMLToArgvHelper (qemuxml2argvtest.c:105)
      ==2143==    by 0x41E5DD: virtTestRun (testutils.c:145)
      ==2143==    by 0x416FA3: mymain (qemuxml2argvtest.c:399)
      ==2143==    by 0x41DCB7: virtTestMain (testutils.c:700)
      ==2143==    by 0x39CF01ECDC: (below main) (libc-start.c:226)
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      80d476a9
  8. 02 4月, 2012 1 次提交
    • P
      Support clock=variable relative to localtime · b8bf79aa
      Philipp Hahn 提交于
      Since Xen 3.1 the clock=variable semantic is supported. In addition to
      qemu/kvm Xen also knows about a variant where the offset is relative to
      'localtime' instead of 'utc'.
      
      Extends the libvirt structure with a flag 'basis' to specify, if the
      offset is relative to 'localtime' or 'utc'.
      
      Extends the libvirt structure with a flag 'reset' to force the reset
      behaviour of 'localtime' and 'utc'; this is needed for backward
      compatibility with previous versions of libvirt, since they report
      incorrect XML.
      
      Adapt the only user 'qemu' to the new name.
      Extend the RelaxNG schema accordingly.
      Document the new 'basis' attribute in the HTML documentation.
      Adapt test for the new attribute.
      Signed-off-by: NPhilipp Hahn <hahn@univention.de>
      b8bf79aa
  9. 31 3月, 2012 3 次提交
    • E
      conf: allow fuzz in XML with cur balloon > max · d400b8fb
      Eric Blake 提交于
      Commit 1b1402b9 introduced a regression.  Since older libvirt versions
      would silently round memory up (until the previous patch), but populated
      current memory based on querying the guest, it was possible to have
      dumpxml show cur > max by the amount of the rounding.  For example, if
      a user requested 1048570 KiB memory (just shy of 1GiB), the qemu
      driver would actually run with 1048576 KiB, and libvirt 0.9.10 would
      output a current that was 6KiB larger than the maximum.  Situations
      where this could have an impact include, but are not limited to,
      migration from old to new libvirt, managedsave in old libvirt and
      start in new libvirt, snapshot creation in old libvirt and revert in
      new libvirt - without this patch, the new libvirt would reject the
      VM because of the rounding discrepancy.
      
      Fix things by adding a fuzz factor, and silently clamp current down to
      maximum in that case, rather than failing to reparse XML for an existing
      VM.  From a practical standpoint, this has no user impact: 'virsh
      dumpxml' will continue to query the running guest rather than rely on
      the incoming xml, which will see the currect current value, and even if
      clamping down occurs during parsing, it will be by at most the fuzz
      factor of a megabyte alignment, and rounded back up when passed back to
      the hypervisor.
      
      Meanwhile, we continue to reject cur > max if the difference is beyond
      the fuzz factor of nearest megabyte.  But this is not a real change in
      behavior, since with 0.9.10, even though the parser allowed it, later
      in the processing stream we would reject it at the qemu layer; so
      rejecting it in the parser just moves error detection to a nicer place.
      
      * src/conf/domain_conf.c (virDomainDefParseXML): Don't reject
      existing XML.
      Based on a report by Zhou Peng.
      d400b8fb
    • E
      build: fix build on cygwin · 87681495
      Eric Blake 提交于
      Regression introduced when we changed types in commit 3e2c3d8f.
      
      We've done this sort of cleanup before (see commit c685993d).
      
      * src/conf/storage_conf.c (virStoragePoolDefFormat)
      (virStorageVolTargetDefFormat): Cast gid_t and uid_t.
      87681495
    • L
      Revert "Set default name for SPICE agent channel" · 1133ee2b
      Laine Stump 提交于
      This patch reverts commit b0e2bb33. Its functionality has been replaced
      by commit 3269ee65.
      1133ee2b
  10. 30 3月, 2012 1 次提交
  11. 29 3月, 2012 1 次提交
    • C
      Set default name for SPICE agent channel · b0e2bb33
      Christophe Fergeau 提交于
      libvirt documentation for channels with type 'spicevmc' says that the
      'target' child node has:
      "an optional attribute name controls how the guest will have access
       to the channel, and defaults to name='com.redhat.spice.0'."
      
      However, this default value is never set in libvirt code base,
      there's only a check in qemu_command.c to error out if the name
      attribute doesn't have the expected value (if it's set).
      
      This commit sets a default target name for spicevmc channels during
      the domain configuration parsing so that the code agrees with the
      documentation.
      b0e2bb33
  12. 27 3月, 2012 2 次提交
    • D
      Add support for setting init argv for LXC · c91cff25
      Daniel P. Berrange 提交于
      Pass argv to the init binary of LXC, using a new <initarg> element.
      
      * docs/formatdomain.html.in: Document <os> usage for containers
      * docs/schemas/domaincommon.rng: Add <initarg> element
      * src/conf/domain_conf.c, src/conf/domain_conf.h: parsing and
        formatting of <initarg>
      * src/lxc/lxc_container.c: Setup LXC argv
      * tests/Makefile.am, tests/lxcxml2xmldata/lxc-systemd.xml,
        tests/lxcxml2xmltest.c, tests/testutilslxc.c,
        tests/testutilslxc.h: Test parsing/formatting of LXC related
        XML parts
      c91cff25
    • M
      Cleanup for a return statement in source files · 9943276f
      Martin Kletzander 提交于
      Return statements with parameter enclosed in parentheses were modified
      and parentheses were removed. The whole change was scripted, here is how:
      
      List of files was obtained using this command:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$'
      
      Found files were modified with this command:
      sed -i -e                                                                 \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      
      Then checked for nonsense.
      
      The whole command looks like this:
      git grep -l -e '\<return\s*([^()]*\(([^()]*)[^()]*\)*)\s*;' |             \
      grep -e '\.[ch]$' -e '\.py$' | xargs sed -i -e                            \
      's_^\(.*\<return\)\s*(\(\([^()]*([^()]*)[^()]*\)*\))\s*\(;.*$\)_\1 \2\4_' \
      -e 's_^\(.*\<return\)\s*(\([^()]*\))\s*\(;.*$\)_\1 \2\3_'
      9943276f
  13. 23 3月, 2012 5 次提交
    • O
      New domain state pmsuspended · 54d9026a
      Osier Yang 提交于
      This introduces a new domain state pmsuspended to represent
      the domain which has been suspended by guest power management,
      e.g. (entered itno s3 state). Because a "running" state could
      be confused in this case, one will see the guest is paused
      actually while playing. And state "paused" is for the domain
      which was paused by virDomainSuspend.
      54d9026a
    • O
      Add support for the suspend event · 487c0633
      Osier Yang 提交于
      This patch introduces a new event type for the QMP event
      SUSPEND:
      
          VIR_DOMAIN_EVENT_ID_PMSUSPEND
      
      The event doesn't take any data, but considering there might
      be reason for wakeup in future, the callback definition is:
      
      typedef void
      (*virConnectDomainEventSuspendCallback)(virConnectPtr conn,
                                              virDomainPtr dom,
                                              int reason,
                                              void *opaque);
      
      "reason" is unused currently, always passes "0".
      487c0633
    • O
      Add support for the wakeup event · 57ddcc23
      Osier Yang 提交于
      This patch introduces a new event type for the QMP event
      WAKEUP:
      
          VIR_DOMAIN_EVENT_ID_PMWAKEUP
      
      The event doesn't take any data, but considering there might
      be reason for wakeup in future, the callback definition is:
      
      typedef void
      (*virConnectDomainEventWakeupCallback)(virConnectPtr conn,
                                             virDomainPtr dom,
                                             int reason,
                                             void *opaque);
      
      "reason" is unused currently, always passes "0".
      57ddcc23
    • O
      conf: Parse and for the tray attribute · b22eaa75
      Osier Yang 提交于
      The "tray" is only allowed for removable disks, i.e. CDROM and
      Floppy disks.
      b22eaa75
    • O
      Add support for event tray moved of removable disks · a26a1969
      Osier Yang 提交于
      This patch introduces a new event type for the QMP event
      DEVICE_TRAY_MOVED, which occurs when the tray of a removable
      disk is moved (i.e opened or closed):
      
          VIR_DOMAIN_EVENT_ID_TRAY_CHANGE
      
      The event's data includes the device alias and the reason
      for tray status' changing, which indicates why the tray
      status was changed. Thus the callback definition for the event
      is:
      
      enum {
          VIR_DOMAIN_EVENT_TRAY_CHANGE_OPEN = 0,
          VIR_DOMAIN_EVENT_TRAY_CHANGE_CLOSE,
      
      \#ifdef VIR_ENUM_SENTINELS
          VIR_DOMAIN_EVENT_TRAY_CHANGE_LAST
      \#endif
      } virDomainEventTrayChangeReason;
      
      typedef void
      (*virConnectDomainEventTrayChangeCallback)(virConnectPtr conn,
                                                 virDomainPtr dom,
                                                 const char *devAlias,
                                                 int reason,
                                                 void *opaque);
      a26a1969
  14. 20 3月, 2012 2 次提交
    • 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
    • L
      conf: return immediately on error in dhcp host element · 43d635ca
      Laine Stump 提交于
      If an error was encountered parsing a dhcp host entry mac address or
      name, parsing would continue and log a less descriptive error that
      might make it more difficult to notice the true nature of the problem.
      
      This patch returns immediately on logging the first error.
      43d635ca
  15. 16 3月, 2012 1 次提交
    • D
      Add support for forcing a private network namespace for LXC guests · 10a8b1f9
      Daniel P. Berrange 提交于
      If no <interface> elements are included in an LXC guest XML
      description, then the LXC guest will just see the host's
      network interfaces. It is desirable to be able to hide the
      host interfaces, without having to define any guest interfaces.
      
      This patch introduces a new feature flag <privnet/> to allow
      forcing of a private network namespace for LXC. In the future
      I also anticipate that we will add <privuser/> to force a
      private user ID namespace.
      
      * src/conf/domain_conf.c, src/conf/domain_conf.h: Add support
        for <privnet/> feature. Auto-set <privnet> if any <interface>
        devices are defined
      * src/lxc/lxc_container.c: Honour request for private network
        namespace
      10a8b1f9
  16. 15 3月, 2012 1 次提交
    • 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
  17. 13 3月, 2012 2 次提交
    • M
      graphics: Cleanup port policy · 2e4defdc
      Michal Privoznik 提交于
      Even though we say in documentation setting (tls-)port to -1 is legacy
      compat style for enabling autoport, we're roughly doing this for VNC.
      However, in case of SPICE auto enable autoport iff both port & tlsPort
      are equal -1 as documentation says autoport plays with both.
      2e4defdc
    • J
      qemu: Fix (managed)save and snapshots with host mode CPU · 041109af
      Jiri Denemark 提交于
      When host-model and host-passthrouh CPU modes were introduced, qemu
      driver was properly modify to update guest CPU definition during
      migration so that we use the right CPU at the destination. However,
      similar treatment is needed for (managed)save and snapshots since they
      need to save the exact CPU so that a domain can be properly restored.
      To avoid repetition of such situation, all places that need live XML
      share the code which generates it.
      
      As a side effect, this patch fixes error reporting from
      qemuDomainSnapshotWriteMetadata().
      041109af
  18. 09 3月, 2012 4 次提交
    • L
      conf: eliminate redundant VIR_ALLOC of 1st element of network DNS hosts. · b5893b7b
      Laine Stump 提交于
      virNetworkDNSHostsDefParseXML was calling VIR_ALLOC(def->hosts) if
      def->hosts was NULL. This is a waste of time, though, since
      VIR_REALLOC_N is called a few lines further down, prior to any use of
      def->hosts. (initializing def->nhosts to 0 is also redundant, because
      the newly allocated memory will always be cleared to all 0's anyway).
      b5893b7b
    • P
      qemu: spice agent-mouse support · 896e6ac4
      Peng Zhou 提交于
      spice agent-mouse support
      
      Usage:
        <graphics type='spice'>
          <mouse mode='client'|'server'/>
        <graphics/>
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      896e6ac4
    • L
      util: eliminate device object leaks related to virDomain*Remove*() · f985773d
      Laine Stump 提交于
      There are several functions in domain_conf.c that remove a device
      object from the domain's list of that object type, but don't free the
      object or return it to the caller to free. In many cases this isn't a
      problem because the caller already had a pointer to the object and
      frees it afterward, but in several cases the removed object was just
      left floating around with no references to it.
      
      In particular, the function qemuDomainDetachDeviceConfig() calls
      functions to locate and remove net (virDomainNetRemoveByMac), disk
      (virDomainDiskRemoveByName()), and lease (virDomainLeaseRemove())
      devices, but neither it nor its caller qemuDomainModifyDeviceConfig()
      ever obtain a pointer to the device being removed, much less free it.
      
      This patch modifies the following "remove" functions to return a
      pointer to the device object being removed from the domain device
      arrays, to give the caller the option of freeing the device object
      using that pointer if needed. In places where the object was
      previously leaked, it is now freed:
      
        virDomainDiskRemove
        virDomainDiskRemoveByName
        virDomainNetRemove
        virDomainNetRemoveByMac
        virDomainHostdevRemove
        virDomainLeaseRemove
        virDomainLeaseRemoveAt
      
      The functions that had been leaking:
      
        libxlDomainDetachConfig - leaked a virDomainDiskDef
        qemuDomainDetachDeviceConfig - could leak a virDomainDiskDef,
                                  a virDomainNetDef, or a
                                  virDomainLeaseDef
        qemuDomainDetachLease   - leaked a virDomainLeaseDef
      f985773d
    • L
      util: make virDomainLeaseDefFree global · 8845d293
      Laine Stump 提交于
      It will be used in a different file in an upcoming patch.
      8845d293
  19. 08 3月, 2012 6 次提交
    • 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
      xml: allow scaled memory on input · 2e22f23b
      Eric Blake 提交于
      Output is still in kibibytes, but input can now be in different
      scales for ease of typing.
      
      * src/conf/domain_conf.c (virDomainParseMemory): New helper.
      (virDomainDefParseXML): Use it when parsing.
      * docs/schemas/domaincommon.rng: Expand XML; rename memoryKBElement
      to memoryElement and update callers.
      * docs/formatdomain.html.in (elementsMemoryAllocation): Document
      scaling.
      * tests/qemuxml2argvdata/qemuxml2argv-memtune.xml: Adjust test.
      * tests/qemuxml2xmltest.c: Likewise.
      * tests/qemuxml2xmloutdata/qemuxml2xmlout-memtune.xml: New file.
      2e22f23b
    • E
      xml: use better types for memory values · 4888f0fb
      Eric Blake 提交于
      Using 'unsigned long' for memory values is risky on 32-bit platforms,
      as a PAE guest can have more than 4GiB memory.  Our API is
      (unfortunately) locked at 'unsigned long' and a scale of 1024, but
      the rest of our system should consistently use 64-bit values,
      especially since the previous patch centralized overflow checking.
      
      * src/conf/domain_conf.h (_virDomainDef): Always use 64-bit values
      for memory.  Change hugepage_backed to a bool.
      * src/conf/domain_conf.c (virDomainDefParseXML)
      (virDomainDefCheckABIStability, virDomainDefFormatInternal): Fix
      clients.
      * src/vmx/vmx.c (virVMXFormatConfig): Likewise.
      * src/xenxs/xen_sxpr.c (xenParseSxpr, xenFormatSxpr): Likewise.
      * src/xenxs/xen_xm.c (xenXMConfigGetULongLong): New function.
      (xenXMConfigGetULong, xenXMConfigSetInt): Avoid truncation.
      (xenParseXM, xenFormatXM): Fix clients.
      * src/phyp/phyp_driver.c (phypBuildLpar): Likewise.
      * src/openvz/openvz_driver.c (openvzDomainSetMemoryInternal):
      Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainDefineXML): Likewise.
      * src/qemu/qemu_command.c (qemuBuildCommandLine): Likewise.
      * src/qemu/qemu_process.c (qemuProcessStart): Likewise.
      * src/qemu/qemu_monitor.h (qemuMonitorGetBalloonInfo): Likewise.
      * src/qemu/qemu_monitor_text.h (qemuMonitorTextGetBalloonInfo):
      Likewise.
      * src/qemu/qemu_monitor_text.c (qemuMonitorTextGetBalloonInfo):
      Likewise.
      * src/qemu/qemu_monitor_json.h (qemuMonitorJSONGetBalloonInfo):
      Likewise.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBalloonInfo):
      Likewise.
      * src/qemu/qemu_driver.c (qemudDomainGetInfo)
      (qemuDomainGetXMLDesc): Likewise.
      * src/uml/uml_conf.c (umlBuildCommandLine): Likewise.
      4888f0fb
    • E
      xml: drop unenforced minimum memory limit from RNG · 1b1402b9
      Eric Blake 提交于
      The test domain allows <memory>0</memory>, but the RNG was stating
      that memory had to be at least 4096000 bytes.  Hypervisors should
      enforce their own limits, rather than complicating the RNG.
      
      Meanwhile, some copy and paste had introduced some fishy constructs
      in various unit tests.
      
      * docs/schemas/domaincommon.rng (memoryKB, memoryKBElement): Drop
      limit that isn't enforced in code.
      * src/conf/domain_conf.c (virDomainDefParseXML): Require current
      <= maximum.
      * tests/qemuxml2argvdata/*.xml: Fix offenders.
      1b1402b9
    • E
      storage: support more scaling suffixes · 2e148612
      Eric Blake 提交于
      Disk manufacturers are fond of quoting sizes in powers of 10,
      rather than powers of 2 (after all, 2.1 GB sounds larger than
      2.0 GiB, even though the exact opposite is true).  So, we might
      as well follow coreutils' lead in supporting three types of
      suffix: single letter ${u} (which we already had) and ${u}iB
      for the power of 2, and ${u}B for power of 10.
      
      Additionally, it is impossible to create a file with more than
      2**63 bytes, since off_t is signed (if you have enough storage
      to even create one 8EiB file, I'm jealous).  This now reports
      failure up front rather than down the road when the kernel
      finally refuses an impossible size.
      
      * docs/schemas/basictypes.rng (unit): Add suffixes.
      * src/conf/storage_conf.c (virStorageSize): Use new function.
      * docs/formatstorage.html.in: Document it.
      * tests/storagevolxml2xmlin/vol-file-backing.xml: Test it.
      * tests/storagevolxml2xmlin/vol-file.xml: Likewise.
      2e148612
    • E
      xml: output memory unit for clarity · 26545784
      Eric Blake 提交于
      Make it obvious to 'dumpxml' readers what unit we are using,
      since our default of KiB for memory (1024) differs from qemu's
      default of MiB; and differs from our use of bytes for storage.
      
      Tests were updated via:
      
      $ find tests/*data tests/*out -name '*.xml' | \
        xargs sed -i 's/<\(memory\|currentMemory\|hard_limit\|soft_limit\|min_guarantee\|swap_hard_limit\)>/<\1 unit='"'KiB'>/"
      $ find tests/*data tests/*out -name '*.xml' | \
        xargs sed -i 's/<\(capacity\|allocation\|available\)>/<\1 unit='"'bytes'>/"
      
      followed by a few fixes for the stragglers.
      
      Note that with this patch, the RNG for <memory> still forbids
      validation of anything except unit='KiB', since the code silently
      ignores the attribute; a later patch will expand <memory> to allow
      scaled input in the code and update the RNG to match.
      
      * docs/schemas/basictypes.rng (unit): Add 'bytes'.
      (scaledInteger): New define.
      * docs/schemas/storagevol.rng (sizing): Use it.
      * docs/schemas/storagepool.rng (sizing): Likewise.
      * docs/schemas/domaincommon.rng (memoryKBElement): New define; use
      for memory elements.
      * src/conf/storage_conf.c (virStoragePoolDefFormat)
      (virStorageVolDefFormat): Likewise.
      * src/conf/domain_conf.h (_virDomainDef): Document unit used
      internally.
      * src/conf/storage_conf.h (_virStoragePoolDef, _virStorageVolDef):
      Likewise.
      * tests/*data/*.xml: Update all tests.
      * tests/*out/*.xml: Likewise.
      * tests/define-dev-segfault: Likewise.
      * tests/openvzutilstest.c (testReadNetworkConf): Likewise.
      * tests/qemuargv2xmltest.c (blankProblemElements): Likewise.
      26545784
  20. 07 3月, 2012 1 次提交
  21. 06 3月, 2012 3 次提交
    • L
      conf: change virDomainNetRemove from static to global · ac9ca01c
      Laine Stump 提交于
      This exact code is duplicated in qemuDomainDetachNetDevice().
      ac9ca01c
    • L
      qemu: support type='hostdev' network devices at domain start · 8639a420
      Laine Stump 提交于
      This patch makes sure that each network device ("interface") of
      type='hostdev' appears on both the hostdevs list and the nets list of
      the virDomainDef, and it modifies the qemu driver startup code so that
      these devices will be presented to qemu on the commandline as hostdevs
      rather than as network devices.
      
      It does not add support for hotplug of these type of devices, or code
      to honor the <mac address> or <virtualport> given in the config (both
      of those will be done in separate patches).
      
      Once each device is placed on both lists, much of what this patch does
      is modify places in the code that traverse all the device lists so
      that these hybrid devices are only acted on once - either along with
      the other hostdevs, or along with the other network interfaces. (In
      many cases, only one of the lists is traversed / a specific operation
      is performed on only one type of device. In those instances, the code
      can remain unchanged.)
      
      There is one special case - when building the commandline, interfaces
      are allowed to proceed all the way through
      networkAllocateActualDevice() before deciding to skip the rest of
      netdev-specific processing - this is so that (once we have support for
      networks with pools of hostdev devices) we can get the actual device
      allocated, then rely on the loop processing all hostdevs to generate
      the correct commandline.
      
      (NB: <interface type='hostdev'> is only supported for PCI network
      devices that are SR-IOV Virtual Functions (VF). Standard PCI[e] and
      USB devices, and even the Physical Functions (PF) of SR-IOV devices
      can only be assigned to a guest using the more basic <hostdev> device
      entry. This limitation is mostly due to the fact that non-SR-IOV
      ethernet devices tend to lose mac address configuration whenever the
      card is reset, which happens when a card is assigned to a guest;
      SR-IOV VFs fortunately don't suffer the same problem.)
      8639a420
    • 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