1. 07 1月, 2014 18 次提交
    • J
      qemu: Fix job usage in virDomainGetBlockIoTune · 3b564259
      Jiri Denemark 提交于
      CVE-2013-6458
      
      Every API that is going to begin a job should do that before fetching
      data from vm->def.
      3b564259
    • J
      qemu: Fix job usage in qemuDomainBlockCopy · ff5f30b6
      Jiri Denemark 提交于
      Every API that is going to begin a job should do that before fetching
      data from vm->def.
      ff5f30b6
    • J
      qemu: Fix job usage in qemuDomainBlockJobImpl · f93d2caa
      Jiri Denemark 提交于
      CVE-2013-6458
      
      Every API that is going to begin a job should do that before fetching
      data from vm->def.
      f93d2caa
    • J
      qemu: Avoid using stale data in virDomainGetBlockInfo · b7992595
      Jiri Denemark 提交于
      CVE-2013-6458
      
      Generally, every API that is going to begin a job should do that before
      fetching data from vm->def. However, qemuDomainGetBlockInfo does not
      know whether it will have to start a job or not before checking vm->def.
      To avoid using disk alias that might have been freed while we were
      waiting for a job, we use its copy. In case the disk was removed in the
      meantime, we will fail with "cannot find statistics for device '...'"
      error message.
      b7992595
    • J
      qemu: Do not access stale data in virDomainBlockStats · db86da5c
      Jiri Denemark 提交于
      CVE-2013-6458
      https://bugzilla.redhat.com/show_bug.cgi?id=1043069
      
      When virDomainDetachDeviceFlags is called concurrently to
      virDomainBlockStats: libvirtd may crash because qemuDomainBlockStats
      finds a disk in vm->def before getting a job on a domain and uses the
      disk pointer after getting the job. However, the domain in unlocked
      while waiting on a job condition and thus data behind the disk pointer
      may disappear. This happens when thread 1 runs
      virDomainDetachDeviceFlags and enters monitor to actually remove the
      disk. Then another thread starts running virDomainBlockStats, finds the
      disk in vm->def, and while it's waiting on the job condition (owned by
      the first thread), the first thread finishes the disk removal. When the
      second thread gets the job, the memory pointed to be the disk pointer is
      already gone.
      
      That said, every API that is going to begin a job should do that before
      fetching data from vm->def.
      db86da5c
    • Y
      Fix segmentation fault when accessing default qemu machine type · 72953074
      Yudai Yamagish 提交于
      This patch fixes a segmentation fault when creating new virtual machines using QEMU.
      The segmentation fault is caused by commit f4183068
      and commit cbb6ec42.
      
      In virQEMUCapsProbeQMPMachineTypes, when copying machines to qemuCaps, "none" is skipped.
      Therefore, the value of i and "qemuCaps->nmachineTypes - 1" do not always match.
      However, defIdx value (used to call virQEMUCapsSetDefaultMachine) is set using the value in i
      when the array elements are in qemuCaps->nmachineTypes - 1.
      So, when libvirt tries to create virtual machines using the default machine type,
      qemuCaps->machineTypes[defIdx] is accessed and since the defIdx is NULL, it results in segmentation fault.
      Signed-off-by: NYudai Yamagishi <yummy@sfc.wide.ad.jp>
      Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
      72953074
    • E
      maint: inline VIR_IS_CONNECT macro · 968fe2c8
      Eric Blake 提交于
      Cleanup after commit db3dd082 removed all clients outside of
      the .h file.
      
      * src/datatypes.h (VIR_IS_CONNECT): Delete, and inline into all
      callers, since no other file uses it any more.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      968fe2c8
    • E
      event: make deregister return value match docs · 31b5bad9
      Eric Blake 提交于
      Ever since their introduction (commit 1509b802 in v0.5.0 for
      virConnectDomainEventRegister, commit 44457238 in v0.8.0 for
      virConnectDomainEventDeregisterAny), the event deregistration
      functions have been documented as returning 0 on success;
      likewise for older registration (only the newer RegisterAny
      must return a non-zero callbackID).  And now that we are
      adding virConnectNetworkEventDeregisterAny for v1.2.1, it
      should have the same semantics.
      
      Fortunately, all of the stateful drivers have been obeying
      the docs and returning 0, thanks to the way the remote_driver
      tracks things (in fact, the RPC wire protocol is unable to
      send a return value for DomainEventRegisterAny, at least not
      without adding a new RPC number).  Well, except for vbox,
      which was always failing deregistration, due to failure to
      set the return value to anything besides its initial -1.
      
      But for local drivers, such as test:///default, we've been
      returning non-zero numbers; worse, the non-zero numbers have
      differed over time.  For example, in Fedora 12 (libvirt 0.8.2),
      calling Register twice would return 0 and 1 [the callbackID
      generated under the hood]; while in Fedora 20 (libvirt 1.1.3),
      it returns 1 and 2 [the number of callbacks registered for
      that event type].  Since we have changed the behavior over
      time, and since it differs by local vs. remote, we can safely
      argue that no one could have been reasonably relying on any
      particular behavior, so we might as well obey the docs, as well
      as prepare callers that might deal with older clients to not be
      surprised if the docs are not strictly followed.
      
      For consistency, this patch fixes the code for all drivers,
      even though it only makes an impact for vbox and for local
      drivers.  By fixing all drivers, future copy and paste from
      a remote driver to a local driver is less likely to
      reintroduce the bug.
      
      Finally, update the testsuite to gain some coverage of the
      issue for local drivers, including the first test of old-style
      domain event registration via function pointer instead of
      event id.
      
      * src/libvirt.c (virConnectDomainEventRegister)
      (virConnectDomainEventDeregister)
      (virConnectDomainEventDeregisterAny): Clarify docs.
      * src/libxl/libxl_driver.c (libxlConnectDomainEventRegister)
      (libxlConnectDomainEventDeregister)
      (libxlConnectDomainEventDeregisterAny): Match documentation.
      * src/lxc/lxc_driver.c (lxcConnectDomainEventRegister)
      (lxcConnectDomainEventDeregister)
      (lxcConnectDomainEventDeregisterAny): Likewise.
      * src/test/test_driver.c (testConnectDomainEventRegister)
      (testConnectDomainEventDeregister)
      (testConnectDomainEventDeregisterAny)
      (testConnectNetworkEventDeregisterAny): Likewise.
      * src/uml/uml_driver.c (umlConnectDomainEventRegister)
      (umlConnectDomainEventDeregister)
      (umlConnectDomainEventDeregisterAny): Likewise.
      * src/vbox/vbox_tmpl.c (vboxConnectDomainEventRegister)
      (vboxConnectDomainEventDeregister)
      (vboxConnectDomainEventDeregisterAny): Likewise.
      * src/xen/xen_driver.c (xenUnifiedConnectDomainEventRegister)
      (xenUnifiedConnectDomainEventDeregister)
      (xenUnifiedConnectDomainEventDeregisterAny): Likewise.
      * src/network/bridge_driver.c
      (networkConnectNetworkEventDeregisterAny): Likewise.
      * tests/objecteventtest.c (testDomainCreateXMLOld): New test.
      (mymain): Run it.
      (testDomainCreateXML): Check return values.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      31b5bad9
    • M
      qemuProcessStop: Don't overwrite any errors · 088ff08c
      Michal Privoznik 提交于
      Currently, the qemuProcessStop tries to open the domain log file
      and saves the original error afterwards. Then all the cleanup is
      done after which the error is restored back. This has however one
      flaw: if opening of the log file fails an error is reported,
      which results in previous error being overwritten (the useful
      one, e.g. "PCI device XXXX:XXXX could not be found"). Hence, user
      sees something like:
      
        error: failed to create logfile /var/log/libvirt/qemu/ovirt_usb.log: No such file or directory
      
      instead of:
      
        error: internal error: Did not find USB device 8644:8003
      Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
      Reported-by: NZhou Yimin <zhouyimin@huawei.com>
      088ff08c
    • E
      maint: fix comment typos in qemu numa code · 599ef94d
      Eric Blake 提交于
      Introduced in commit 81fae6b9.
      
      * src/qemu/qemu_driver.c (qemuDomainSetNumaParamsLive): Fix typos.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      599ef94d
    • R
      BSD: implement nodeGetMemoryStats · e7a65dc7
      Roman Bogorodskiy 提交于
      Add a BSD implementation of nodeGetMemoryStats based
      on sysctl(3).
      e7a65dc7
    • M
      Fix argument order of qemuMigrationPerformJob(). · bcd0ac47
      Minoru Usui 提交于
      @listenAddress and @cookiein arguments, should be exchanged,
      because the order of the caller and the callee does not match.
      
      This results in the listen address being ignored for peer-to-peer
      migration and the cookie being ignored for v2 migration.
      
      Introduced by c4ac7ef6 (v1.1.4-rc1~141).
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1049338Signed-off-by: NMinoru Usui <usui@mxm.nes.nec.co.jp>
      Signed-off-by: NJán Tomko <jtomko@redhat.com>
      bcd0ac47
    • P
      maint: Fix messy include of libvirt_internal.h · aef39eb0
      Peter Krempa 提交于
      The libvirt_internal.h header was included by the internal.h header.
      This made it painful to add new stuff to the header file that would
      require some more specific types. Remove inclusion by internal.h and add
      it to appropriate places manually.
      aef39eb0
    • E
      maint: improve VIR_ERR_INVALID_CONN usage · db3dd082
      Eric Blake 提交于
      The datatype.c object checks could result in a message like:
      
      error: invalid connection pointer in no connection
      
      This consolidates all clients of this message to have uniform contents:
      
      error: invalid connection pointer in someFunc
      
      Note that virCheckConnectReturn raises an error immediately; in
      datatypes.c, where we don't need to raise the error (but instead
      just leave it in the thread-local setting), we use
      virCheckConnectGoto and the cleanup label instead.  Then, for
      consistency in that file, all subsequent error messages are
      touched to also use the cleanup error label.
      
      * src/datatypes.h (virCheckConnectReturn)
      (virCheckConnectGoto): New macros.
      * src/datatypes.c: Use new macro.
      * src/libvirt-qemu.c (virDomainQemuAttach): Likewise.
      (virLibConnError): Delete unused macro.
      * src/libvirt-lxc.c (virLibConnError): Likewise.
      * src/libvirt.c: Use new macro throughout.
      * docs/api_extension.html.in: Modernize documentation.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      db3dd082
    • J
      libxl: Fix initialization of nictype in libxl_device_nic · 7c98d1c1
      Jim Fehlig 提交于
      As pointed out by the Xen folks [1], HVM nics should always be set
      to type LIBXL_NIC_TYPE_VIF_IOEMU unless the user explicity requests
      LIBXL_NIC_TYPE_VIF via model='netfront'.  The current logic in
      libxlMakeNic() only sets the nictype to LIBXL_NIC_TYPE_VIF_IOEMU if
      a model is specified that is not 'netfront', which breaks PXE booting
      configurations where no model is specified (i.e. use the hypervisor
      default).
      Reported-by: NStefan Bader <stefan.bader@canonical.com>
      
      [1] https://www.redhat.com/archives/libvir-list/2013-December/msg01156.html
      7c98d1c1
    • E
      Revert "lxcDomainShutdownFlags: Cleanup @flags usage" · f3e359d6
      Eric Blake 提交于
      This reverts commit aa461933.
      
      This patch was accidentally pushed prematurely, and has incorrect
      logic for which shutdown methods to attempt.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f3e359d6
    • E
      build: fix bootstrap with older autoconf · 8531301d
      Eric Blake 提交于
      Pavel Hrdina reported to me off-list that my gnulib update on
      Jan 1 broke the build on RHEL 6.4 (autoconf 2.63) and older:
      
          executing aclocal -I glm4
          glm4/gl-openssl.m4:11: error: m4_defn: undefined macro: _m4_divert_diversion
          glm4/gl-openssl.m4:11: the top level
          autom4te: /usr/bin/m4 failed with exit status: 1
          aclocal: autom4te failed with exit status: 1
      
      It took me a while, but I fixed the regression in gnulib.
      
      * gnulib: Update to latest, for build fixes.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      8531301d
    • P
      AArch64: Porting of armv7l conditons to run qemu for aarch64. · 27e32e0f
      Pranavkumar Sawargaonkar 提交于
      AArch64 qemu has similar behavior as armv7l, like use of mmio etc.
      This patch adds similar bypass checks what we have for armv7l to aarch64.
      E.g. we are enabling mmio transport for Nicdev.
      Making addDefaultUSB and addDefaultMemballoon to false etc.
      
      V3:
      - Adding missing domain rng schema for aarcg64 and test case in
        testutilsqemu.c which was causing test suite failure
        while running make check.
      
      V2:
      - Added testcase to qemuxml2argvtest as suggested
        during review comments of V1.
      
      V1:
      - Initial patch.
      Signed-off-by: NAnup Patel <anup.patel@linaro.org>
      Signed-off-by: NPranavkumar Sawargaonkar <pranavkumar@linaro.org>
      27e32e0f
  2. 06 1月, 2014 7 次提交
    • E
      maint: improve VIR_ERR_OPERATION_DENIED usage · d219826c
      Eric Blake 提交于
      Some of our operation denied messages are outright stupid; for
      example, if virIdentitySetAttr fails:
      
      error: operation Identity attribute is already set forbidden for read only access
      
      This patch fixes things to a saner:
      
      error: operation forbidden: Identity attribute is already set
      
      It also consolidates the most common usage pattern for operation
      denied errors: read-only connections preventing a public API.  In
      this case, 'virsh -r -c test:///default destroy test' changes from:
      
      error: operation virDomainDestroy forbidden for read only access
      
      to:
      
      error: operation forbidden: read only access prevents virDomainDestroy
      
      Note that we were previously inconsistent on which APIs used
      VIR_FROM_DOM (such as virDomainDestroy) vs. VIR_FROM_NONE (such as
      virDomainPMSuspendForDuration).  After this patch, all uses
      consistently use VIR_FROM_NONE, on the grounds that it is unlikely
      that a caller learning that a call is denied can do anything in
      particular with extra knowledge which error domain the call belongs
      to (similar to what we did in commit baa72449).
      
      * src/util/virerror.c (virErrorMsg): Rework OPERATION_DENIED error
      message.
      * src/internal.h (virCheckReadOnlyGoto): New macro.
      * src/util/virerror.h (virReportRestrictedError): New macro.
      * src/libvirt-lxc.c: Use new macros.
      * src/libvirt-qemu.c: Likewise.
      * src/libvirt.c: Likewise.
      * src/locking/lock_daemon.c (virLockDaemonClientNew): Likewise.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d219826c
    • 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
  3. 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
  4. 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
  5. 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
  6. 02 1月, 2014 4 次提交
    • 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
    • E
      tests: fix syntax in previous patch · 53e3f9e4
      Eric Blake 提交于
      'make syntax-check' wasn't happy with commit fb004207.
      
      * tests/virnetsockettest.c (checkProtocols): Typo fix.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      53e3f9e4
    • R
      aarch64: Fix sysinfo test. · 1063a0ff
      Richard W.M. Jones 提交于
      On AArch64 the kernel prints one "processor" (lower case 'p') line per
      core.  As this was missing from the test data, virSysinfo was not
      parsing any processors at all.
      
      Fix the test data so the test now passes.
      1063a0ff