1. 06 1月, 2014 6 次提交
    • P
      qemu: range check numa memory placement mode · 6e7490c7
      Peter Krempa 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1047234
      
      Add a range check for supported numa memory placement modes provided by
      the user before setting them in the domain definition. Without the check
      the user is able to provide a (yet) unknown mode which is then stored in
      the domain definition. This potentially causes a NULL dereference when
      the defintion is formatted into the XML.
      
      To reproduce run:
       virsh numatune DOMNAME --mode 6 --nodeset 0
      
      The XML will then contain:
        <numatune>
            <memory mode='(null)' nodeset='0'/>
        </numatune>
      
      With this fix, the command fails:
       error: Unable to change numa parameters
       error: invalid argument: unsupported numa_mode: '6'
      6e7490c7
    • P
      qemu: Clean up qemuDomainSetNumaParameters · 8b573a6b
      Peter Krempa 提交于
      Add whitespace to separate logical code blocks, reformat error messages
      and clean up code flow.
      
      This patch changes error handling in some cases where the the loop would
      be continued to jump to cleanup instead and error out rather than modify
      the domain any further.
      8b573a6b
    • P
      storage: Use VIR_DELETE_ELEMENT instead of open coding · cad3cf9a
      Peter Krempa 提交于
      Replace the open coded array element deletion by our new helper.
      cad3cf9a
    • E
      event: use newer array management macros · 94a26c7e
      Eric Blake 提交于
      We might as well take advantage of viralloc.h instead of open-coding
      array management ourselves.  While at it, I simplified several
      places that were doing repetitive pointer chasing to use an
      intermediate variable for legibility (some other places remain,
      but they will disapper in later refactoring patches).
      
      * src/conf/object_event_private.h (_virObjectEventCallbackList):
      Use size_t for count.
      * src/conf/object_event.c (_virObjectEventQueue): Likewise.
      (virObjectEventCallbackListRemoveID): Use VIR_DELETE_ELEMENT.
      (virObjectEventQueuePush, virObjectEventCallbackListAddID): Use
      VIR_APPEND_ELEMENT.
      (virObjectEventCallbackListEventID)
      (virObjectEventStateDispatchCallbacks): Simplify code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      94a26c7e
    • E
      event: use bool in more places · 22e82aa5
      Eric Blake 提交于
      No need to use an int that only ever stores 0 and 1.
      
      * src/conf/object_event_private.h (_virObjectEventCallback):
      Change deleted to bool.
      * src/conf/object_event.c (virObjectEventDispatchMatchCallback):
      Switch return type to bool.
      (virObjectEventCallbackListMarkDeleteID): Update client.
      * src/conf/domain_event.c (virDomainEventCallbackListMarkDelete):
      Likewise.
      22e82aa5
    • J
      Fix explicit usage of default video PCI slots · ec128e69
      Ján Tomko 提交于
      Do not leave the PCI address of the primary video card set
      to the legacy default (0000:00:02.0) if we're doing two-pass
      allocation.
      
      Since QEMU 1.6 (QEMU_CAPS_VIDEO_PRIMARY) we allow the primary
      video card to be on other slots than 0000:00:02.0 (as we use
      -device instead of -vga).
      
      However we fail to assign it an address if:
      * another device explicitly uses 0000:00:02.0 and
      * the primary video device has no address specified
      
      On the first pass, we have set the address to default, then checked
      if it's available, leaving it set even if it wasn't. This address
      got picked up by the second pass, resulting in a conflict:
      
      XML error: Attempted double use of PCI slot 0000:00:02.0
      (may need "multifunction='on'" for device on function 0)
      
      Also fix the test that was supposed to catch this.
      ec128e69
  2. 05 1月, 2014 1 次提交
    • E
      maint: improve VIR_ERR_NO_SUPPORT usage · baa72449
      Eric Blake 提交于
      We weren't very consistent in our use of VIR_ERR_NO_SUPPORT; many
      users just passed __FUNCTION__ on, while others passed "%s" to
      silence over-eager compilers that warn about __FUNCTION__ not
      containing any %.  It's nicer to route all these uses through
      a single macro, so that if we ever need to change the reporting,
      we can do it in one place.
      
      I verified that 'virsh -c test:///default qemu-monitor-command test foo'
      gives the same error message before and after this patch:
      error: this function is not supported by the connection driver: virDomainQemuMonitorCommand
      
      Note that in libvirt.c, we were inconsistent on whether virDomain*
      API used virLibConnError() (with VIR_FROM_NONE) or virLibDomainError()
      (with VIR_FROM_DOMAIN); this patch unifies these errors to all use
      VIR_FROM_NONE, on the grounds that it is unlikely that a caller
      learning that a call is unimplemented can do anything in particular
      with extra knowledge of which error domain it belongs to.
      
      One particular change to note is virDomainOpenGraphics which was
      trying to fail with VIR_ERR_NO_SUPPORT after a failed
      VIR_DRV_SUPPORTS_FEATURE check; all other places that fail a
      feature check report VIR_ERR_ARGUMENT_UNSUPPORTED.
      
      * src/util/virerror.h (virReportUnsupportedError): New macro.
      * src/libvirt-qemu.c: Use new macro.
      * src/libvirt-lxc.c: Likewise.
      * src/lxc/lxc_driver.c: Likewise.
      * src/security/security_manager.c: Likewise.
      * src/util/virinitctl.c: Likewise.
      * src/libvirt.c: Likewise.
      (virDomainOpenGraphics): Use correct error for unsupported feature.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      baa72449
  3. 04 1月, 2014 5 次提交
    • E
      maint: avoid nested public calls · 8f6c845f
      Eric Blake 提交于
      Having one API call into another is generally not good; among
      other issues, it gives confusing logs, and is not quite as
      efficient.
      
      This fixes several instances, but not all: we still have instances
      in both libvirt.c and in backend hypervisors (lxc and qemu) calling
      the public virTypedParamsGetString and friends, which dispatch
      errors immediately.  I'm not sure if it is worth trying to clean
      that up in a separate patch (such a cleanup may be easiest by
      separating the public function into a wrapper around the internal,
      then tweaking internal.h so that internal users directly use the
      internal function).
      
      * src/libvirt.c (virDomainGetUUIDString, virNetworkGetUUIDString)
      (virStoragePoolGetUUIDString, virSecretGetUUIDString)
      (virNWFilterGetUUIDString): Avoid nested public API call.
      * src/util/virtypedparam.c (virTypedParamsReplaceString): Don't
      dispatch errors here.
      (virTypedParamsGet): No need to reset errors.
      (virTypedParamsGetBoolean): Use consistent ordering.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8f6c845f
    • D
      vmware: os x support is broken · d69415d4
      Denis Kondratenko 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=1036248
      
      Incorrect usage of virAsprintf.  vmware-vmx reports version
      information to stderr, at least for OS X 10.9.1.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d69415d4
    • E
      event: remove unneeded virObjectEventGetEventID · 344e1f51
      Eric Blake 提交于
      Any file with access to object_event_private.h also has access to
      the internals of virObjectEvent, without needing an accessor
      function.  Not to mention the accessor function was doing type
      checks that would always succeed.
      
      * src/conf/object_event_private.h (virObjectEventGetEventID): Drop.
      * src/conf/object_event.c (virObjectEventGetEventID): Drop.
      (virObjectEventDispatchMatchCallback): Simplify caller.
      * src/conf/domain_event.c (virDomainEventDispatchDefaultFunc):
      Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      344e1f51
    • E
      event: fix doc typos, and doc more public methods · 6742fb0b
      Eric Blake 提交于
      While working on events, I found a number of minor issues; I'm
      hoisting these to the front rather than doing it piecemeal in
      the patches where I first noticed bad or missing documentation.
      
      * src/conf/object_event.c: Fix grammar, document all parameters
      of public functions, wrap some long lines.
      * src/conf/object_event.h: Likewise.
      * src/conf/network_event.c: Likewise.
      * src/conf/domain_event.c: Likewise (except for the large number
      of event creation functions).
      * src/libvirt_private.cyms (conf/object_event.h): Split...
      (conf/network_event.h): ...to account for new file.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      6742fb0b
    • E
      maint: reset error on entrance to public API · f06d55da
      Eric Blake 提交于
      We document that calling any public API wipes out all prior
      libvirt errors in the same thread; but weren't obeying this
      style in a few functions.
      
      There are a couple of nested uses of virConnectRef (in lxc
      and qemu reboot paths), but they should not be affected by
      this change in semantics since there should not be any
      previous error getting nuked (a later patch will clean up
      the nested calls, along with abuse of virConnectClose on
      cleanup paths which DOES nuke errors).
      
      * src/libvirt.c (virGetVersion, virConnectRef, virDomainRef)
      (virDomainGetSecurityLabel, virDomainGetSecurityLabelList)
      (virDomainSetMetadata, virDomainGetMetadata)
      (virNodeGetSecurityModel, virNetworkRef, virInterfaceRef)
      (virStoragePoolRef, virStorageVolRef, virNodeDeviceGetName)
      (virNodeDeviceRef, virSecretRef, virStreamRef, virNWFilterRef)
      (virDomainSnapshotRef): Reset error on entrance.
      (do_open): Drop redundant error reset.
      * src/libvirt-qemu.c (virDomainQemuAgentCommand): Likewise.
      * src/libvirt-lxc.c (virDomainLxcEnterNamespace)
      (virDomainLxcEnterSecurityLabel): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f06d55da
  4. 03 1月, 2014 5 次提交
    • E
      maint: improve error condition style in public API · ca0ea2a9
      Eric Blake 提交于
      While auditing error messages in libvirt.c, I found a couple
      instances that had not been converted to modern error styles,
      and a few places that failed to dispatch the error through
      the known-good connection.
      
      * src/libvirt.c (virDomainPinEmulator, virDomainGetDiskErrors)
      (virDomainSendKey, virDomainGetSecurityLabelList)
      (virDomainGetEmulatorPinInfo): Use typical error reporting.
      (virConnectGetCPUModelNames, virConnectRegisterCloseCallback)
      (virConnectUnregisterCloseCallback, virDomainGetUUID): Report
      error through connection.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ca0ea2a9
    • E
      maint: split long lines in invalidArg errors · 5e3e211d
      Eric Blake 提交于
      Style only.  In particular, the message on "flags 'affect live'
      and 'affect config'" being mutually exclusive was already split
      in some instances.
      
      * src/libvirt.c: Wrap some long error messages to fit in 80 columns.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      5e3e211d
    • E
      maint: move debug statements first in public API · ff658434
      Eric Blake 提交于
      Most of our public APIs emit a debug log on entry, prior to anything
      else.  There were a few exceptions where obvious failures were not
      logged, so fix those.  When moving a debug earlier, this patch also
      makes sure to avoid any NULL dereference during the log (the APIs
      are supposed to gracefully fail if the user passes NULL for the object).
      
      However, do NOT use VIR_DEBUG prior to virInitialize, since setting
      up the error reporting can change where VIR_DEBUG output would be
      routed.  Instead add documentation to virGlobalInit, virInitialize,
      and virGetVersion that better explains initialization.
      
      * src/libvirt.c (virGetVersion, virConnectRef, virDomainRef)
      (virNetworkRef, virInterfaceRef, virStoragePoolRef)
      (virStorageVolRef, virNodeDeviceRef, virSecretRef, virStreamRef)
      (virNWFilterRef, virDomainSnapshotRef): Debug on function entry.
      * src/libvirt-lxc.c (virDomainLxcEnterNamespace)
      (virDomainLxcEnterSecurityLabel): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      ff658434
    • E
      maint: improve debug of libvirt-{qemu,lxc} apis · 13f83720
      Eric Blake 提交于
      I noticed that the virDomainQemuMonitorCommand debug output wasn't
      telling me the name of the domain it was working on.  While it was
      easy enough to determine which pointer matches the domain based on
      other log messages, it is nicer to be consistent.
      
      * src/util/viruuid.h (VIR_UUID_DEBUG): Moved here from...
      * src/libvirt.c (VIR_UUID_DEBUG): ...here.
      (VIR_ARG15, VIR_HAS_COMMA, VIR_DOMAIN_DEBUG_EXPAND)
      (VIR_DOMAIN_DEBUG_PASTE, VIR_DOMAIN_DEBUG_0, VIR_DOMAIN_DEBUG_1)
      (VIR_DOMAIN_DEBUG_2, VIR_DOMAIN_DEBUG): Move...
      * src/datatypes.h: ...here.
      * src/libvirt-qemu.c (virDomainQemuMonitorCommand)
      (virDomainQemuAgentCommand): Better debug messages.
      * src/libvirt-lxc.c (virDomainLxcOpenNamespace): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      13f83720
    • E
      maint: consistent formatting in libvirt.c · 80aed9f8
      Eric Blake 提交于
      Preliminary cleanups to make search-and-replace easier in later
      patches.  Many of these were done by grepping for (multiline)
      pattern violations, then bundled all into one patch.
      
      * src/libvirt.c: Uniform two spaces between functions, return
      type and open brace on separate line, avoid blank lines around
      open brace, label in column 1, drop redundant (), consistent
      indentation for function headers split across lines.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      80aed9f8
  5. 02 1月, 2014 2 次提交
    • E
      event: improve public API docs · c8f95fff
      Eric Blake 提交于
      Since libvirt 0.9.3, the entire virevent.c file has been a public
      API, so improve the documentation in this file.  Also, fix a
      potential core dump - it could only be triggered by bogus use of
      the API and would only affect the caller (not libvirtd), but we
      might as well be nice.
      
      * src/libvirt.c (virConnectSetKeepAlive)
      (virConnectDomainEventRegister, virConnectDomainEventRegisterAny)
      (virConnectNetworkEventRegisterAny): Document event loop requirement.
      * src/util/virevent.c (virEventAddHandle, virEventRemoveHandle)
      (virEventAddTimeout, virEventRemoveTimeout): Likewise.
      (virEventUpdateHandle, virEventUpdateTimeout): Likewise, and avoid
      core dump if caller didn't register handler.
      (virEventRunDefaultImpl): Expand example, and set up code block in
      html docs.
      (virEventRegisterImpl, virEventRegisterDefaultImpl): Document more
      on the use of the event loop.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      c8f95fff
    • E
      event: don't overwrite registration error message · cfd62c1f
      Eric Blake 提交于
      Prior to this patch, an attempt to register an event without an
      event loop started results in the vague:
      
      libvirt: Remote Driver error : adding cb to list
      
      Now it gives the much nicer:
      
      libvirt:  error : internal error: could not initialize domain event timer
      
      This also avoids hiding other reasonable error messages, such as
      attempts to register a duplicate callback or OOM errors.
      
      * src/remote/remote_driver.c (remoteConnectNetworkEventRegisterAny)
      (remoteConnectDomainEventRegister)
      (remoteConnectDomainEventRegisterAny): Preserve more detailed error.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cfd62c1f
  6. 01 1月, 2014 1 次提交
    • E
      docs: return paragraph must be last · 16970097
      Eric Blake 提交于
      Commit eb70ceba tried to create a code block for
      libvirt-libvirt.html#virConnectGetType, but failed to note
      that our doc generator treats everything after "Returns" as
      part of the return description rather than looking for
      paragraph and code layout.  Fix some other API that also had
      generic details crammed into the return type paragraph.
      
      * src/libvirt.c (virConnectOpen, virConnectOpenReadOnly)
      (virConnectOpenAuth, virConnectListAllDomains): Fit doc pattern.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      16970097
  7. 31 12月, 2013 1 次提交
    • L
      domain: don't try to interpret <driver> as virtio config for hostdev interfaces · 3337a98a
      Laine Stump 提交于
      This resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1046337
      
      The <driver> name attribute of an interface is interpreted in two
      different ways depending on the <interface> type - if the interface is
      type='hostdev', then the driver name describes which backend to use
      for the hostdev device assignment (vfio or kvm), but if the interface
      is any emulated type *and* the model type is "virtio", then the driver
      name can be "vhost" or "qemu", telling which backend qemu should use
      to communicate with the emulated device.
      
      The problem comes when someone has defined a an interface like this
      (which is accepted by the parser as long as no <driver name='xxx'/> is
      specified):
      
          <interface type='hostdev'>
             ...
             <model type='virtio'/>
             ...
          </interface>
      
      As libvirt storing this definition in the domain's status, the driver
      name is automatically filled in with the backend that was
      automatically decided by libvirt, so it stores this in the status:
      
          <interface type='hostdev'>
             ...
             <driver name='vfio'/>
             ...
             <model type='virtio'/>
             ...
          </interface>
      
      This isn't noticed until the next time libvirtd is restarted - as it
      is reading the status of all domains, it encounters the above
      interface definition, logs an error:
      
        internal error: Unknown interface <driver name='vfio'> has been specified
      
      and fails to reload the domain status, so the domain is marked as
      inactive.
      
      The solution is to stop the parser from interpreting <driver>
      attributes as if the device was an emulated virtio device, when it is
      actually a hostdev.
      
      (Although the bug has existed since vfio support was added, it has
      just recently become more apparent because libvirt previously didn't
      automatically set the driver name for hostdev interfaces in the domain
      status to vfio/kvm as it does since commit f094aa, first appearing in
      v1.1.4.)
      3337a98a
  8. 29 12月, 2013 1 次提交
  9. 28 12月, 2013 1 次提交
  10. 25 12月, 2013 4 次提交
  11. 24 12月, 2013 3 次提交
    • D
      libxl: correctly handle affinity reset in virDomainPinVcpu[Flags] · 9375ba2a
      Dario Faggioli 提交于
      By actually removing the <vcpupin> element (from within the
      <cputune> section) from the XML, rather than jus update it with
      a fully set vcpu affinity mask.
      Signed-off-by: NDario Faggioli <dario.faggioli@citrix.com>
      Cc: Jim Fehlig <jfehlig@suse.com>
      Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
      9375ba2a
    • D
      libxl: implement virDomainPinVcpuFlags · 520c3fbd
      Dario Faggioli 提交于
      And use it to implement libxlDomainPinVcpu(), similarly to what
      happens in the QEMU driver. This way, it is possible to both
      query and change the vcpu affinity of a persistent but not
      running domain.
      
      In face, before this patch, we have:
       # virsh list --all
        Id    Name                           State
       ----------------------------------------------------
        5     debian_32                      running
        -     fedora20_64                    shut off
       # virsh vcpupin fedora20_64 0 2-4 --current
       error: this function is not supported by the connection driver: virDomainPinVcpuFlags
      
      After (same situation as above):
       # virsh vcpupin  fedora20_64 0 2-4 --current
       # virsh vcpupin  fedora20_64 0
       VCPU: CPU Affinity
       ----------------------------------
          0: 2-4
      Signed-off-by: NDario Faggioli <dario.faggioli@citrix.com>
      Cc: Jim Fehlig <jfehlig@suse.com>
      Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
      520c3fbd
    • D
      libxl: implement virDomainGetVcpuPinInfo · 2682d0d5
      Dario Faggioli 提交于
      So that it is possible to query vcpu related information of
      a persistent but not running domain, like it is for the QEMU
      driver.
      
      In fact, before this patch, we have:
       # virsh list --all
        Id    Name                           State
       ----------------------------------------------------
        5     debian_32                      running
        -     fedora20_64                    shut off
       # virsh vcpuinfo fedora20_64
       error: this function is not supported by the connection driver: virDomainGetVcpuPinInfo
      
      After (same situation as above, i.e., fedora20_64 not running):
       # virsh vcpuinfo fedora20_64
       VCPU:           0
       CPU:            N/A
       State:          N/A
       CPU time        N/A
       CPU Affinity:   yyyyyyyy
      
       VCPU:           1
       CPU:            N/A
       State:          N/A
       CPU time        N/A
       CPU Affinity:   yyyyyyyy
      Signed-off-by: NDario Faggioli <dario.faggioli@citrix.com>
      Cc: Jim Fehlig <jfehlig@suse.com>
      Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
      2682d0d5
  12. 23 12月, 2013 3 次提交
    • L
      qemu: re-add hostdev interfaces to hostdev array on libvirtd restart · 8700b878
      Laine Stump 提交于
      This resolves:
      
         https://bugzilla.redhat.com/show_bug.cgi?id=1045002
      
      If a domain has an <interface type='hostdev'> or an <interface
      type='network'> where the network itself is a pool of hostdev devices,
      then libvirt will internally keep that device on both the interface
      list *and* the hostdev list for the domain. One of the places this
      comes in handy is when a new device is being added and libvirt wants
      to find a unique "alias" name for it - it just scans through the
      hostdev array and makes sure it picks a name that doesn't match the
      alias of any device in that array.
      
      However, when libvirtd was restarted, if there was an <interface
      type='network'> with the network being a hostdev pool, the device
      would not be added to the reconstructed internal hostdev array, so its
      alias would not be found during a scan of the hostdev array, thus
      attempts to add a new hostdev (or <interface type='hostdev'> or
      <interface type='network'>) would result in a message like this:
      
      internal error: unable to execute QEMU command 'device_add':
                      Duplicate ID 'hostdev0' for device
      
      This patch simply fixes the existing code in the domain XML parser
      that fixes up the hostdev array in the case of <interface
      type='hostdev'> to do the same thing in the case of <interface
      type='network'> with a hostdev network.
      
      This bug has existed since the very first addition of hostdev networks
      to libvirt (0.10.0).
      8700b878
    • L
      qemu: avoid duplicate security label restore on hostdev attach failure · c0f511ee
      Laine Stump 提交于
      This eliminates the misleading error message that was being logged
      when a vfio hostdev hotplug failed:
      
        error: unable to set user and group to '107:107' on '/dev/vfio/22':
               No such file or directory
      
      as documented in:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1035490
      
      Commit ee414b5d (pushed as a fix for Bug 1016511 and part of Bug
      1025108) replaced the single call to
      virSecurityManagerSetHostdevLabel() in qemuDomainAttachHostDevice()
      with individual calls to that same function in each
      device-type-specific attach function (for PCI, USB, and SCSI). It also
      added a corresponding call to virSecurityManagerRestoreHostdevLabel()
      in the error handling of the device-type-specific functions, but
      forgot to remove the common call to that from
      qemuDomainAttachHostDevice() - this resulted in a duplicate call to
      virSecurityManagerRestoreHostdevLabel(), with the second occurrence
      being after (e.g.) a PCI device has already been re-attached to the
      host driver, thus destroying some of the device nodes / links that we
      then attempted to re-label (e.f. /dev/vfio/22) and generating an error
      log that obscured the original error.
      c0f511ee
    • L
      qemu: properly set MaxMemLock when hotplugging with VFIO · 6d867f72
      Laine Stump 提交于
      This resolves:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=1035490
      
      virProcessSetMaxMemLock() (which is a wrapper over prlimit(3)) expects
      the memory size in bytes, but libvirt's domain definition (which was
      being used by qemuDomainAttachHostPciDevice()) stores all memory
      tuning parameters in KiB. This was being accounted for when setting
      MaxMemLock at domain startup time (so cold-plugged devices would
      work), but not for hotplug.
      
      This patch simplifies the few lines that call
      virProcessSetMemMaxLock(), and multiply the amount * 1024 so that
      we're locking the correct amount of memory.
      
      What remains a mystery to me is why hot-plug of a managed='no' device
      would succeed (at least on my system) while managed='yes' would
      fail. I guess in one case the memory was coincidentally already
      resident and in the other it wasn't.
      6d867f72
  13. 21 12月, 2013 3 次提交
    • J
      PanicCheckABIStability: Need to check for existence · d53c57b8
      John Ferlan 提交于
      Commit id '4313fead' added a call to virDomainPanicCheckABIStability()
      which did not check whether the panic device existed before making a call
      to virDomainDeviceInfoCheckABIStability() which ended up segfaulting:
      
      Thread 1 (Thread 0x7f5332837700 (LWP 10964)):
          (src=<optimized out>, dst=<optimized out>)
          at conf/domain_conf.c:13007
          (dst=<optimized out>, src=<optimized out>)
          at conf/domain_conf.c:13712
          (src=<optimized out>, dst=<optimized out>)
          at conf/domain_conf.c:14056
          (domain=domain@entry=0x7f53000057c0, vm=vm@entry=0x7f53000036d0,
           defptr=defptr@entry=0x7f5332836978, snap=snap@entry=0x7f5332836970,
           update_current=update_current@entry=0x7f5332836962, flags=flags@entry=1)
          at conf/snapshot_conf.c:1230
          (domain=0x7f53000057c0, xmlDesc=<optimized out>, flags=1)
          at qemu/qemu_driver.c:12719
          (domain=domain@entry=0x7f53000057c0, xmlDesc=0x7f53000081d0
           "<domainsnapshot>\n  <name>snap2</name>\n
           <description>new-desc</description>\n  <state>running</state>\n
           <parent>\n    <name>snap1</name>\n  </parent>\n
           <creationTime>1387487268</creationTime>\n  <memory s"..., flags=1)
          at libvirt.c:19695
      ...
      
      (gdb) up 3
      (gdb) print *other->def->dom
      $2 = {virtType = 2, id = -1, ..
      ...
        rng = 0x0, panic = 0x0, namespaceData = 0x0,...
      ...
      (gdb) print *def->dom
      $3 = {virtType = 2, id = -1, ...
      ...
        rng = 0x0, panic = 0x0, namespaceData = 0x0,...
      ...
      (gdb)
      
      Also seen using following sequence:
      
      virsh save $dom $file
      virsh save-image-edit $file
        add (or remove) a <panic/> line
        <devices>
        ...
          <panic>
            <address type='isa' iobase='0x505'/>
          </panic>
        ...
        </devices>
      d53c57b8
    • B
      libxl: fix segfault when domain create fail · b03eba13
      Bamvor Jian Zhang 提交于
      there is a segfault in libxl logging in libxl_ctx_free when domain
      create fail. because the log output handler vmessage is freed by
      xtl_logger_destroy before libxl_ctx_free in virDomainObjListRemove.
      move xtl_logger_destroy after libxl_ctx_free could fix this bug.
      Signed-off-by: NBamvor Jian Zhang <bjzhang@suse.com>
      b03eba13
    • D
      libxl: avoid crashing if calling `virsh numatune' on inactive domain · f9ee91d3
      Dario Faggioli 提交于
      by, in libxlDomainGetNumaParameters(), calling libxl_bitmap_init() as soon as
      possible, which avoids getting to 'cleanup:', where libxl_bitmap_dispose()
      happens, without having initialized the nodemap, and hence crashing after some
      invalid free()-s:
      
       # ./daemon/libvirtd -v
       *** Error in `/home/xen/libvirt.git/daemon/.libs/lt-libvirtd': munmap_chunk(): invalid pointer: 0x00007fdd42592666 ***
       ======= Backtrace: =========
       /lib64/libc.so.6(+0x7bbe7)[0x7fdd3f767be7]
       /lib64/libxenlight.so.4.3(libxl_bitmap_dispose+0xd)[0x7fdd2c88c045]
       /home/xen/libvirt.git/daemon/.libs/../../src/.libs/libvirt_driver_libxl.so(+0x12d26)[0x7fdd2caccd26]
       /home/xen/libvirt.git/src/.libs/libvirt.so.0(virDomainGetNumaParameters+0x15c)[0x7fdd4247898c]
       /home/xen/libvirt.git/daemon/.libs/lt-libvirtd(+0x1d9a2)[0x7fdd42ecc9a2]
       /home/xen/libvirt.git/src/.libs/libvirt.so.0(virNetServerProgramDispatch+0x3da)[0x7fdd424e9eaa]
       /home/xen/libvirt.git/src/.libs/libvirt.so.0(+0x1a6f38)[0x7fdd424e3f38]
       /home/xen/libvirt.git/src/.libs/libvirt.so.0(+0xa81e5)[0x7fdd423e51e5]
       /home/xen/libvirt.git/src/.libs/libvirt.so.0(+0xa783e)[0x7fdd423e483e]
       /lib64/libpthread.so.0(+0x7c53)[0x7fdd3febbc53]
       /lib64/libc.so.6(clone+0x6d)[0x7fdd3f7e1dbd]
      Signed-off-by: NDario Faggili <dario.faggioli@citrix.com>
      Cc: Jim Fehlig <jfehlig@suse.com>
      Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>
      f9ee91d3
  14. 20 12月, 2013 4 次提交
    • M
      Fix crash in lxcDomainSetMemoryParameters · 9faf3f29
      Martin Kletzander 提交于
      The function doesn't check whether the request is made for active or
      inactive domain.  Thus when the domain is not running it still tries
      accessing non-existing cgroups (priv->cgroup, which is NULL).
      
      I re-made the function in order for it to work the same way it's qemu
      counterpart does.
      
      Reproducer:
       1) Define an LXC domain
       2) Do 'virsh memtune <domain> --hard-limit 133T'
      
      Backtrace:
       Thread 6 (Thread 0x7fffec8c0700 (LWP 26826)):
       #0  0x00007ffff70edcc4 in virCgroupPathOfController (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", path=0x7fffec8bf718) at util/vircgroup.c:1764
       #1  0x00007ffff70e9206 in virCgroupSetValueStr (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", value=0x7fffe409f360 "1073741824")
           at util/vircgroup.c:669
       #2  0x00007ffff70e98b4 in virCgroupSetValueU64 (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", value=1073741824) at util/vircgroup.c:740
       #3  0x00007ffff70ee518 in virCgroupSetMemory (group=0x0, kb=1048576) at util/vircgroup.c:1904
       #4  0x00007ffff70ee675 in virCgroupSetMemoryHardLimit (group=0x0, kb=1048576)
           at util/vircgroup.c:1944
       #5  0x00005555557d54c8 in lxcDomainSetMemoryParameters (dom=0x7fffe40cc420,
           params=0x7fffe409f100, nparams=1, flags=0) at lxc/lxc_driver.c:774
       #6  0x00007ffff72c20f9 in virDomainSetMemoryParameters (domain=0x7fffe40cc420,
           params=0x7fffe409f100, nparams=1, flags=0) at libvirt.c:4051
       #7  0x000055555561365f in remoteDispatchDomainSetMemoryParameters (server=0x555555eb7e00,
           client=0x555555ec4b10, msg=0x555555eb94e0, rerr=0x7fffec8bfb70, args=0x7fffe40b8510)
           at remote_dispatch.h:7621
       #8  0x00005555556133fd in remoteDispatchDomainSetMemoryParametersHelper (server=0x555555eb7e00,
           client=0x555555ec4b10, msg=0x555555eb94e0, rerr=0x7fffec8bfb70, args=0x7fffe40b8510,
           ret=0x7fffe40b84f0) at remote_dispatch.h:7591
       #9  0x00007ffff73b293f in virNetServerProgramDispatchCall (prog=0x555555ec3ae0,
           server=0x555555eb7e00, client=0x555555ec4b10, msg=0x555555eb94e0)
           at rpc/virnetserverprogram.c:435
       #10 0x00007ffff73b207f in virNetServerProgramDispatch (prog=0x555555ec3ae0,
           server=0x555555eb7e00, client=0x555555ec4b10, msg=0x555555eb94e0)
           at rpc/virnetserverprogram.c:305
       #11 0x00007ffff73a4d2c in virNetServerProcessMsg (srv=0x555555eb7e00, client=0x555555ec4b10,
           prog=0x555555ec3ae0, msg=0x555555eb94e0) at rpc/virnetserver.c:165
       #12 0x00007ffff73a4e8d in virNetServerHandleJob (jobOpaque=0x555555ec3e30, opaque=0x555555eb7e00)
           at rpc/virnetserver.c:186
       #13 0x00007ffff7187f3f in virThreadPoolWorker (opaque=0x555555eb7ac0) at util/virthreadpool.c:144
       #14 0x00007ffff718733a in virThreadHelper (data=0x555555eb7890) at util/virthreadpthread.c:161
       #15 0x00007ffff468ed89 in start_thread (arg=0x7fffec8c0700) at pthread_create.c:308
       #16 0x00007ffff3da26bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      9faf3f29
    • M
      CVE-2013-6436: fix crash in lxcDomainGetMemoryParameters · f8c1cb90
      Martin Kletzander 提交于
      The function doesn't check whether the request is made for active or
      inactive domain.  Thus when the domain is not running it still tries
      accessing non-existing cgroups (priv->cgroup, which is NULL).
      
      I re-made the function in order for it to work the same way it's qemu
      counterpart does.
      
      Reproducer:
       1) Define an LXC domain
       2) Do 'virsh memtune <domain>'
      
      Backtrace:
       Thread 6 (Thread 0x7fffec8c0700 (LWP 13387)):
       #0  0x00007ffff70edcc4 in virCgroupPathOfController (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", path=0x7fffec8bf750) at util/vircgroup.c:1764
       #1  0x00007ffff70e958c in virCgroupGetValueStr (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", value=0x7fffec8bf7c0) at util/vircgroup.c:705
       #2  0x00007ffff70e9d29 in virCgroupGetValueU64 (group=0x0, controller=3,
           key=0x7ffff75734bd "memory.limit_in_bytes", value=0x7fffec8bf810) at util/vircgroup.c:804
       #3  0x00007ffff70ee706 in virCgroupGetMemoryHardLimit (group=0x0, kb=0x7fffec8bf8a8)
           at util/vircgroup.c:1962
       #4  0x00005555557d590f in lxcDomainGetMemoryParameters (dom=0x7fffd40024a0,
           params=0x7fffd40027a0, nparams=0x7fffec8bfa24, flags=0) at lxc/lxc_driver.c:826
       #5  0x00007ffff72c28d3 in virDomainGetMemoryParameters (domain=0x7fffd40024a0,
           params=0x7fffd40027a0, nparams=0x7fffec8bfa24, flags=0) at libvirt.c:4137
       #6  0x000055555563714d in remoteDispatchDomainGetMemoryParameters (server=0x555555eb7e00,
           client=0x555555ebaef0, msg=0x555555ebb3e0, rerr=0x7fffec8bfb70, args=0x7fffd40024e0,
           ret=0x7fffd4002420) at remote.c:1895
       #7  0x00005555556052c4 in remoteDispatchDomainGetMemoryParametersHelper (server=0x555555eb7e00,
           client=0x555555ebaef0, msg=0x555555ebb3e0, rerr=0x7fffec8bfb70, args=0x7fffd40024e0,
           ret=0x7fffd4002420) at remote_dispatch.h:4050
       #8  0x00007ffff73b293f in virNetServerProgramDispatchCall (prog=0x555555ec3ae0,
           server=0x555555eb7e00, client=0x555555ebaef0, msg=0x555555ebb3e0)
           at rpc/virnetserverprogram.c:435
       #9  0x00007ffff73b207f in virNetServerProgramDispatch (prog=0x555555ec3ae0,
           server=0x555555eb7e00, client=0x555555ebaef0, msg=0x555555ebb3e0)
           at rpc/virnetserverprogram.c:305
       #10 0x00007ffff73a4d2c in virNetServerProcessMsg (srv=0x555555eb7e00, client=0x555555ebaef0,
           prog=0x555555ec3ae0, msg=0x555555ebb3e0) at rpc/virnetserver.c:165
       #11 0x00007ffff73a4e8d in virNetServerHandleJob (jobOpaque=0x555555ebc7e0, opaque=0x555555eb7e00)
           at rpc/virnetserver.c:186
       #12 0x00007ffff7187f3f in virThreadPoolWorker (opaque=0x555555eb7ac0) at util/virthreadpool.c:144
       #13 0x00007ffff718733a in virThreadHelper (data=0x555555eb7890) at util/virthreadpthread.c:161
       #14 0x00007ffff468ed89 in start_thread (arg=0x7fffec8c0700) at pthread_create.c:308
       #15 0x00007ffff3da26bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
      Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
      f8c1cb90
    • E
      docs: improve event-related documentation · 3e67714e
      Eric Blake 提交于
      While looking at event code, I noticed that the documentation was
      trying to refer me to functions that don't exist.  Also fix some
      typos and poor formatting.
      
      * src/libvirt.c (virConnectDomainEventDeregister)
      (virConnectDomainEventRegisterAny)
      (virConnectDomainEventDeregisterAny)
      (virConnectNetworkEventRegisterAny)
      (virConnectNetworkEventDeregisterAny): Link to correct function.
      * include/libvirt.h.in (VIR_DOMAIN_EVENT_CALLBACK)
      (VIR_NETWORK_EVENT_CALLBACK): Likewise.
      (virDomainEventID, virConnectDomainEventGenericCallback)
      (virNetworkEventID, virConnectNetworkEventGenericCallback):
      Improve docs.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      3e67714e
    • E
      storage: fix bogus target in gluster volume xml · 3a96cebc
      Eric Blake 提交于
      Commit 6cd60b68 was flat out broken - it tried to print into the
      wrong variable.  My testing was obviously too cursory (did the
      name get a slash added?); valgrind would have caught the error.
      Thankfully it didn't hit any release.
      
      Reported by Peter Krempa.
      
      * src/storage/storage_backend_gluster.c
      (virStorageBackendGlusterRefreshVol): Fix bogus code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      3a96cebc