1. 10 11月, 2011 5 次提交
    • D
      Expose MTU management APIs · dfb454ce
      Daniel P. Berrange 提交于
      The MTU management APIs are useful to other code inside libvirt,
      so should be exposed as non-static APIs.
      
      * src/util/bridge.c, src/util/bridge.h: Expose virNetDevSetMTU,
        virNetDevSetMTUFromDevice & virNetDevGetMTU
      dfb454ce
    • D
      Turn two int parameters into bools in bridge APIs · d8a62d95
      Daniel P. Berrange 提交于
      * src/util/bridge.c, src/util/bridge.h: s/int/bool/ in
        virNetDevSetOnline and virNetDevBridgeSetSTP
      d8a62d95
    • D
      Rename all brXXXX APIs to follow new convention · dced27c8
      Daniel P. Berrange 提交于
      The existing brXXX APIs in src/util/bridge.h are renamed to
      follow one of three different conventions
      
       - virNetDevXXX       - operations for any type of interface
       - virNetDevBridgeXXX - operations for bridge interfaces
       - virNetDevTapXXX    - operations for tap interfaces
      
      * src/util/bridge.h, src/util/bridge.c: Rename all APIs
      * src/lxc/lxc_driver.c, src/network/bridge_driver.c,
        src/qemu/qemu_command.c, src/uml/uml_conf.c,
        src/uml/uml_driver.c: Update for API renaming
      dced27c8
    • D
      Make all brXXX APIs raise errors, instead of returning errnos · 4f4fd8f7
      Daniel P. Berrange 提交于
      Currently every caller of the brXXX APIs has to store the returned
      errno value and then raise an error message. This results in
      inconsistent error messages across drivers, additional burden on
      the callers and makes the error reporting inaccurate since it is
      hard to distinguish different scenarios from 1 errno value.
      
      * src/util/bridge.c: Raise errors instead of returning errnos
      * src/lxc/lxc_driver.c, src/network/bridge_driver.c,
        src/qemu/qemu_command.c, src/uml/uml_conf.c,
        src/uml/uml_driver.c: Remove error reporting code
      4f4fd8f7
    • D
      Remove 'brControl' object · 6cfeb9a7
      Daniel P. Berrange 提交于
      The bridge management APIs in src/util/bridge.c require a brControl
      object to be passed around. This holds the file descriptor for the
      control socket. This extra object complicates use of the API for
      only a minor efficiency gain, which is in turn entirely offset by
      the need to fork/exec the brctl command for STP configuration.
      
      This patch removes the 'brControl' object entirely, instead opening
      the control socket & closing it again within the scope of each method.
      
      The parameter names for the APIs are also made to consistently use
      'brname' for bridge device name, and 'ifname' for an interface
      device name. Finally annotations are added for non-NULL parameters
      and return check validation
      
      * src/util/bridge.c, src/util/bridge.h: Remove brControl object
        and update API parameter names & annotations.
      * src/lxc/lxc_driver.c, src/network/bridge_driver.c,
        src/uml/uml_conf.h, src/uml/uml_conf.c, src/uml/uml_driver.c,
        src/qemu/qemu_command.c, src/qemu/qemu_conf.h,
        src/qemu/qemu_driver.c: Remove reference to 'brControl' object
      6cfeb9a7
  2. 08 11月, 2011 1 次提交
    • E
      build: fix build on platforms without ptsname_r · f7bd00c1
      Eric Blake 提交于
      MacOS lacks ptsname_r, and gnulib doesn't (yet) provide it.
      But we can avoid it altogether, by using gnulib openpty()
      instead.  Note that we do _not_ want the pt_chown module;
      gnulib uses it only to implement a replacement openpty() if
      the system lacks both openpty() and granpt(), but all
      systems that we currently port to either have at least one of
      openpty() and/or grantpt(), or lack ptys altogether.  That is,
      we aren't porting to any system that requires us to deal with
      the hassle of installing a setuid pt_chown helper just to use
      gnulib's ability to provide openpty() on obscure platforms.
      
      * .gnulib: Update to latest, for openpty fixes
      * bootstrap.conf (gnulib_modules): Add openpty, ttyname_r.
      (gnulib_tool_option_extras): Exclude pt_chown module.
      * src/util/util.c (virFileOpenTty): Rewrite in terms of openpty
      and ttyname_r.
      * src/util/util.h (virFileOpenTtyAt): Delete dead prototype.
      f7bd00c1
  3. 05 11月, 2011 1 次提交
    • E
      build: silence compiler warning on BSD · 4d970fd2
      Eric Blake 提交于
      Building on 64-bit FreeBSD 8.2 complained about a cast between
      a pointer and a smaller integer.  Going through an intermediate
      cast shuts up the compiler.
      
      * src/util/threads-pthread.c (virThreadSelfID): Silence a warning.
      4d970fd2
  4. 02 11月, 2011 2 次提交
    • D
      Fix off-by-one printing month in logging code · 26b74307
      Daniel P. Berrange 提交于
      The field 'mon' in 'struct tm' gives months 0-11, where as
      humans tend to expect months 1-12. Thus the month number
      needing adjusting by 1
      
      * src/util/logging.c: Use human friendly month number
      26b74307
    • W
      fix crash when starting network · 7ab1c25c
      Wen Congyang 提交于
      commit 27908453 introduces a regression, and it will
      cause libvirt crashed when starting network.
      
      The reason is that tapfd may be NULL, but we dereference
      it without checking whether it is NULL.
      7ab1c25c
  5. 30 10月, 2011 1 次提交
    • O
      qemu: Restore the original states of PCI device when restarting daemon · d84b3626
      Osier Yang 提交于
      To support "managed" mode of host PCI device, we record the original
      states (unbind_from_stub, remove_slot, and reprobe) so that could
      reattach the device to host with original driver. But there is no XML
      for theses attrs, and thus after daemon is restarted, we lose the
      original states. It's easy to reproduce:
      
          1) virsh start domain
          2) virsh attach-device dom hostpci.xml (in 'managed' mode)
          3) service libvirtd restart
          4) virsh destroy domain
      
          You will see the device won't be bound to the original driver
      if there was one.
      
      This patch is to solve the problem by introducing internal XML
      (won't be dumped to user, only dumped to status XML). The XML is:
          <origstates>
            <unbind/>
            <remove_slot/>
            <reprobe/>
          </origstates>
      
      Which will be child node of <hostdev><source>...</souce></hostdev>.
      (only for PCI device).
      
      A new struct "virDomainHostdevOrigStates" is introduced for the XML,
      and the according members are updated when preparing the PCI device.
      And function "qemuUpdateActivePciHostdevs" is modified to honor
      the original states. Use of qemuGetPciHostDeviceList is removed
      in function "qemuUpdateActivePciHostdevs", and the "managed" value of
      the device config is honored by the change. This fixes another problem
      alongside:
      
          qemuGetPciHostDeviceList set the device as "managed" force
          regardless of whether the device is configured as "managed='yes'"
          or not in XML, which is not right.
      d84b3626
  6. 29 10月, 2011 1 次提交
  7. 28 10月, 2011 4 次提交
    • R
      util: Fix virUUIDGeneratePseudoRandomBytes · 884b98ad
      Ryota Ozaki 提交于
      It forgets to move a pointer to a buffer for UUID and as a result
      fills only the first byte of the buffer.
      884b98ad
    • T
      bridge: modify for use when sVirt is enabled with qemu · 27908453
      Tyler Coumbes 提交于
      This refactors the TAP creation code out of brAddTap into a new
      function brCreateTap to allow it to be used on its own. I have also
      changed ifSetInterfaceMac to brSetInterfaceMac and exported it since
      it is will be needed by code outside of util/bridge.c in the next
      patch.
      
       AUTHORS                 |    1 +
       src/libvirt_bridge.syms |    2 +
       src/util/bridge.c       |  116 +++++++++++++++++++++++++++++++----------------
       src/util/bridge.h       |    9 ++++
       4 files changed, 89 insertions(+), 39 deletions(-)
      27908453
    • J
      Introduce virXMLSaveFile as a wrapper for virFileRewrite · fef8127c
      Jiri Denemark 提交于
      Every time we write XML into a file we call virEmitXMLWarning to write a
      warning that the file is automatically generated. virXMLSaveFile
      simplifies this into a single step and makes rewriting existing XML file
      safe by using virFileRewrite internally.
      fef8127c
    • J
      Introduce virFileRewrite for safe file rewrite · 559644dd
      Jiri Denemark 提交于
      When saving config files we just overwrite old content of the file. In
      case something fails during that process (e.g. disk gets full) we lose
      both old and new content. This patch makes the process more robust by
      writing the new content into a separate file and only if that succeeds
      the original file is atomically replaced with the new one.
      559644dd
  8. 27 10月, 2011 1 次提交
  9. 25 10月, 2011 1 次提交
  10. 21 10月, 2011 5 次提交
    • E
      snapshot: simplify indentation of network xml · e36da1bd
      Eric Blake 提交于
      More simplifications possible due to auto-indent.  Also,
      <bandwidth> within <actual> was only using 6 instead of 8 spaces.
      
      * src/util/network.h (virVirtualPortProfileFormat)
      (virBandwidthDefFormat): Alter signature.
      * src/util/network.c (virVirtualPortProfileFormat)
      (virBandwidthDefFormat): Alter indentation.
      (virBandwidthChildDefFormat): Tweak to make use easier.
      * src/conf/network_conf.c (virPortGroupDefFormat)
      (virNetworkDefFormat): Adjust callers.
      * src/conf/domain_conf.c (virDomainNetDefFormat): Likewise.
      (virDomainActualNetDefFormat): Likewise, and fix bandwidth
      indentation.
      e36da1bd
    • E
      snapshot: simplify indentation of sysinfo · 9a220665
      Eric Blake 提交于
      The improvements to virBuffer, along with a paradigm shift to pass
      the original buffer through rather than creating a second buffer,
      allow us to shave off quite a few lines of code.
      
      * src/util/sysinfo.h (virSysinfoFormat): Alter signature.
      * src/util/sysinfo.c (virSysinfoFormat, virSysinfoBIOSFormat)
      (virSysinfoSystemFormat, virSysinfoProcessorFormat)
      (virSysinfoMemoryFormat): Change indentation parameter.
      * src/conf/domain_conf.c (virDomainSysinfoDefFormat): Adjust
      caller.
      * src/qemu/qemu_driver.c (qemuGetSysinfo): Likewise.
      9a220665
    • E
      virbuf: add auto-indentation support · fd9c052e
      Eric Blake 提交于
      Rather than having to adjust all callers in a chain to deal with
      indentation, it is nicer to have virBuffer do auto-indentation.
      
      * src/util/buf.h (_virBuffer): Increase size.
      (virBufferAdjustIndent, virBufferGetIndent): New prototypes.
      * src/libvirt_private.syms (buf.h): Export new functions.
      * src/util/buf.c (virBufferAdjustIndent, virBufferGetIndent): New
      functions.
      (virBufferSetError, virBufferAdd, virBufferAddChar)
      (virBufferVasprintf, virBufferStrcat, virBufferURIEncodeString):
      Implement auto-indentation.
      * tests/virbuftest.c (testBufAutoIndent): Test it.
      (testBufInfiniteLoop): Don't rely on internals.
      Idea by Daniel P. Berrange.
      fd9c052e
    • E
      virbuf: more detailed error reporting · 818a9665
      Eric Blake 提交于
      The next patch wants to add some sanity checking, which would
      be a different error than ENOMEM.  Many existing callers blindly
      report OOM failure if virBuf reports an error, and this will be
      wrong in the (unlikely) case that they actually had a usage error
      instead; but since the most common error really is ENOMEM, I'm
      not going to fix all callers.  Meanwhile, new discriminating
      callers can react differently depending on what failure happened.
      
      * src/util/buf.c (virBufferSetError): Add parameter.
      (virBufferGrow, virBufferVasprintf, virBufferEscapeString)
      (virBufferEscapeSexpr, virBufferEscapeShell): Adjust callers.
      818a9665
    • E
      virbuf: fix const-correctness · 5c09b81b
      Eric Blake 提交于
      Although the compiler wasn't complaining (since it was the pointer,
      rather than what was being pointed to, that was actually const), it
      looks quite suspicious to call a function with an argument labeled
      const when the nature of the pointer (virBufferPtr) is hidden behind
      a typedef.  Dropping const makes the function declarations easier
      to read.
      
      * src/util/buf.h: Drop const from all functions that modify buffer
      argument.
      * src/util/buf.c (virBufferSetError, virBufferAdd)
      (virBufferContentAndReset, virBufferFreeAndReset)
      (virBufferAsprintf, virBufferVasprintf, virBufferEscapeString)
      (virBufferEscapeSexpr, virBufferEscape): Fix fallout.
      5c09b81b
  11. 20 10月, 2011 2 次提交
  12. 19 10月, 2011 3 次提交
    • D
      Replace virBufferAdd with virBufferAddLit for const string · c005e523
      Daniel P. Berrange 提交于
      The statement
      
              virBufferAdd(buf, "''", 2);
      
      triggers a syntax-check warning
      
      * src/util/buf.c: Replace virBufferAdd with virBufferAddLit
      c005e523
    • D
      Allow for URI aliases when connecting to libvirt · 777ffbd0
      Daniel P. Berrange 提交于
      This adds support for a libvirt client configuration file
      either /etc/libvirt/libvirt.conf for privileged clients,
      or $HOME/.libvirt/libvirt.conf for unprivileged clients.
      
      It allows one parameter
      
       uri_aliases = [
         "hail=qemu+ssh://root@hail.cloud.example.com/system",
         "sleet=qemu+ssh://root@sleet.cloud.example.com/system",
       ]
      
      Any call to virConnectOpen with a non-NULL URI will first
      attempt to match against the uri_aliases list. An application
      can disable this by using VIR_CONNECT_NO_ALIASES
      
      * docs/uri.html.in: Document URI aliases
      * include/libvirt/libvirt.h.in: Add VIR_CONNECT_NO_ALIASES
      * libvirt.spec.in, mingw32-libvirt.spec.in: Add /etc/libvirt/libvirt.conf
      * src/Makefile.am: Install default config file
      * src/libvirt.c: Add support for URI aliases
      * src/remote/remote_driver.c: Don't try to handle URIs
        with no scheme and which clearly are not paths
      * src/util/conf.c: Don't raise error on virConfFree(NULL)
      * src/xen/xen_driver.c: Don't raise error on URIs
        with no scheme
      777ffbd0
    • G
      virBufferEscapeShell: Emit quotes for the empty string · 04323fbc
      Guido Günther 提交于
      Make the empty string return '' to match cmdEcho's behavior.
      04323fbc
  13. 18 10月, 2011 1 次提交
  14. 15 10月, 2011 3 次提交
    • R
      Add missing strdup return value check · 7c23c34d
      Roopa Prabhu 提交于
      Check strdup return value and fail if error
      Signed-off-by: NRoopa Prabhu <roprabhu@cisco.com>
      7c23c34d
    • R
      macvtap: avoid invalid free · 80b077ee
      Roopa Prabhu 提交于
      Commit 0472f39f plugged a leak, but introduced another bug:
      
      Actually looks like physfndev is conditionally allocated in getPhysfnDev
      Its better to modify getPhysfnDev to allocate physfndev every time.
      80b077ee
    • O
      qemu: Do not reattach PCI device used by other domain when shutdown · 24b8be89
      Osier Yang 提交于
      When failing on starting a domain, it tries to reattach all the PCI
      devices defined in the domain conf, regardless of whether the devices
      are still used by other domain. This will cause the devices to be deleted
      from the list qemu_driver->activePciHostdevs, thus the devices will be
      thought as usable even if it's not true. And following commands
      nodedev-{reattach,reset} will be successful.
      
      How to reproduce:
        1) Define two domains with same PCI device defined in the confs.
        2) # virsh start domain1
        3) # virsh start domain2
        4) # virsh nodedev-reattach $pci_device
      
      You will see the device will be reattached to host successfully.
      As pciDeviceReattach just check if the device is still used by
      other domain via checking if the device is in list driver->activePciHostdevs,
      however, the device is deleted from the list by step 2).
      
      This patch is to prohibit the bug by:
        1) Prohibit a domain starting or device attachment right at
           preparation period (qemuPrepareHostdevPCIDevices) if the
           device is in list driver->activePciHostdevs, which means
           it's used by other domain.
      
        2) Introduces a new field for struct _pciDevice, (const char *used_by),
           it will be set as the domain name at preparation period,
           (qemuPrepareHostdevPCIDevices). Thus we can prohibit deleting
           the device from driver->activePciHostdevs if it's still used by
           other domain when stopping the domain process.
      
      * src/pci.h (define two internal functions, pciDeviceSetUsedBy and
          pciDevceGetUsedBy)
      * src/pci.c (new field "const char *used_by" for struct _pciDevice,
          implementations for the two new functions)
      * src/libvirt_private.syms (Add the two new internal functions)
      * src/qemu_hostdev.h (Modify the definition of functions
          qemuPrepareHostdevPCIDevices, and qemuDomainReAttachHostdevDevices)
      * src/qemu_hostdev.c (Prohibit preparation and don't delete the
          device from activePciHostdevs list if it's still used by other domain)
      * src/qemu_hotplug.c (Update function usage, as the definitions are
          changed)
      Signed-off-by: NEric Blake <eblake@redhat.com>
      24b8be89
  15. 14 10月, 2011 6 次提交
    • J
      util: Fix typo in virGetHostname description · 57d91fca
      Jiri Denemark 提交于
      57d91fca
    • E
      macvtap: plug memory leak for 802.1Qbh · 0472f39f
      Eric Blake 提交于
      Detected by Coverity.  Leak present since commit ca3b22bb.
      
      * src/util/macvtap.c (doPortProfileOp8021Qbh): Release device name.
      0472f39f
    • G
      Add virBufferEscapeShell · 920487b3
      Guido Günther 提交于
      Escape strings so they're safe to pass to the shell. It's based on
      virsh's cmdEcho.
      920487b3
    • J
      util: Make getaddrinfo failure nonfatal in virGetHostname · f1409fa7
      Jiri Denemark 提交于
      Setting a hostname that cannot be resolved is not the best configuration
      but since virGetHostname only calls getaddrinfo to get host's canonical
      name and we do not fail if the returned canonical name is NULL or
      "localhost", there is no reason why we should fail if getaddrinfo itself
      fails.
      f1409fa7
    • E
      build: add compiler attributes to virUUIDParse · 430156cf
      Eric Blake 提交于
      Coverity complained that most, but not all, clients of virUUIDParse
      were checking for errors.  Silence those coverity warnings by
      explicitly marking the cases where we trust the input, and fixing
      one instance that really should have been checking.  In particular,
      this silences a rather large percentage of the warnings I saw on my
      most recent Coverity analysis run.
      
      * src/util/uuid.h (virUUIDParse): Enforce rules.
      * src/util/uuid.c (virUUIDParse): Drop impossible check; at least
      Coverity will detect if we break rules and pass NULL.
      * src/xenapi/xenapi_driver.c (xenapiDomainCreateXML)
      (xenapiDomainLookupByID, xenapiDomainLookupByName)
      (xenapiDomainDefineXML): Ignore return when we trust data source.
      * src/vbox/vbox_tmpl.c (nsIDtoChar, vboxIIDToUUID_v3_x)
      (vboxCallbackOnMachineStateChange)
      (vboxCallbackOnMachineRegistered, vboxStoragePoolLookupByName):
      Likewise.
      * src/node_device/node_device_hal.c (gather_system_cap): Likewise.
      * src/xenxs/xen_sxpr.c (xenParseSxpr): Check for errors.
      430156cf
    • E
      command: avoid fd leak on failure · 219600c9
      Eric Blake 提交于
      virCommandTransferFD promises that the fd is no longer owned by
      the caller.  Normally, we want the fd to remain open until the
      child runs, but in error situations, we must close it earlier.
      
      * src/util/command.c (virCommandTransferFD): Close fd now if we
      can't track it to close later.
      (virCommandKeepFD): Adjust helper to make this easier.
      219600c9
  16. 13 10月, 2011 1 次提交
  17. 11 10月, 2011 2 次提交
    • D
      Rewrite all the DTrace/SystemTAP probing · ddf3bd32
      Daniel P. Berrange 提交于
      The libvirtd daemon had a few crude system tap probes. Some of
      these were broken during the RPC rewrite. The new modular RPC
      code is structured in a way that allows much more effective
      tracing. Instead of trying to hook up the original probes,
      define a new set of probes for the RPC and event code.
      
      The master probes file is now src/probes.d.  This contains
      probes for virNetServerClientPtr, virNetClientPtr, virSocketPtr
      virNetTLSContextPtr and virNetTLSSessionPtr modules. Also add
      probes for the poll event loop.
      
      The src/dtrace2systemtap.pl script can convert the probes.d
      file into a libvirt_probes.stp file to make use from systemtap
      much simpler.
      
      The src/rpc/gensystemtap.pl script can generate a set of
      systemtap functions for translating RPC enum values into
      printable strings. This works for all RPC header enums (program,
      type, status, procedure) and also the authentication enum
      
      The PROBE macro will automatically generate a VIR_DEBUG
      statement, so any place with a PROBE can remove any existing
      manual DEBUG statements.
      
      * daemon/libvirtd.stp, daemon/probes.d: Remove obsolete probing
      * daemon/libvirtd.h: Remove probe macros
      * daemon/Makefile.am: Remove all probe buildings/install
      * daemon/remote.c: Update authentication probes
      * src/dtrace2systemtap.pl, src/rpc/gensystemtap.pl: Scripts
        to generate STP files
      * src/internal.h: Add probe macros
      * src/probes.d: Master list of probes
      * src/rpc/virnetclient.c, src/rpc/virnetserverclient.c,
        src/rpc/virnetsocket.c, src/rpc/virnettlscontext.c,
        src/util/event_poll.c: Insert probe points, removing any
        DEBUG statements that duplicate the info
      ddf3bd32
    • E
      maint: typo fixes · dbbe16c2
      Eric Blake 提交于
      I noticed a couple typos in recent commits, and fixed the remaining
      instances of them.
      
      * docs/internals/command.html.in: Fix spelling errors.
      * include/libvirt/libvirt.h.in (virConnectDomainEventCallback):
      Likewise.
      * python/libvirt-override.py (virEventAddHandle): Likewise.
      * src/lxc/lxc_container.c (lxcContainerChild): Likewise.
      * src/util/hash.c (virHashCreateFull): Likewise.
      * src/storage/storage_backend_logical.c
      (virStorageBackendLogicalMakeVol): Likewise.
      * src/esx/esx_driver.c (esxFormatVMXFileName): Likewise.
      * src/vbox/vbox_tmpl.c (vboxIIDIsEqual_v3_x): Likewise.
      dbbe16c2