1. 22 7月, 2011 40 次提交
    • O
      remote/ssh: optional "keyfile" parameter. · 6b01c83a
      Oskari Saarenmaa 提交于
      New optional parameter "keyfile" for ssh transport allows the user to select
      the private key to be used to authenticate to the remote host.
      6b01c83a
    • L
      util: make interface.c functions consistently return < 0 on error · f7e18208
      Laine Stump 提交于
      All of the functions in util/interface.c were returning 0 on success,
      but some returned -1 on error, and some returned a positive value
      (usually the value of errno, but sometimes just 1). Libvirt's standard
      is to return < 0 on error (in the case of functions that need to
      return errno, -errno is returned.
      
      This patch modifies all functions in interface.c to consistently
      return < 0 on error, and makes changes to callers of those functions
      where necessary.
      f7e18208
    • D
      Refactor the certification validation code · 637711cb
      Daniel P. Berrange 提交于
      There is some commonality between the code for sanity checking
      certs when initializing libvirt and the code for validating
      certs during a live TLS session handshake. This patchset splits
      up the sanity checking function into several smaller functions
      each doing a specific type of check. The cert validation code
      is then updated to also call into these functions
      
      * src/rpc/virnettlscontext.c: Refactor cert validation code
      637711cb
    • D
      Remove call to deprecated gnutls_certificate_type_set_priority (again) · 3b8061c7
      Daniel P. Berrange 提交于
      The gnutls_certificate_type_set_priority method is deprecated.
      Since we already set the default gnutls priority, it was not
      serving any useful purpose and can be removed
      
      * src/rpc/virnettlscontext.c: Remove gnutls_certificate_type_set_priority
        call
      3b8061c7
    • D
      Ensure that libvirtd shuts down if initialization fails · 92509413
      Daniel P. Berrange 提交于
      If the virStateInitialize call fails we must shutdown libvirtd
      since drivers will not be available. Just free'ing the virNetServer
      is not sufficient, we must send a SIGTERM to ourselves so that
      we interrupt the event loop and trigger a orderly shutdown
      
      * daemon/libvirtd.c: Kill ourselves if state init fails
      * src/rpc/virnetserver.c: Add some debugging to event loop
      92509413
    • A
      Asynchronous event for BlockJob completion · d489b046
      Adam Litke 提交于
      When an operation started by virDomainBlockPull completes (either with
      success or with failure), raise an event to indicate the final status.
      This API allow users to avoid polling on virDomainGetBlockJobInfo if
      they would prefer to use an event mechanism.
      
      * daemon/remote.c: Dispatch events to client
      * include/libvirt/libvirt.h.in: Define event ID and callback signature
      * src/conf/domain_event.c, src/conf/domain_event.h,
        src/libvirt_private.syms: Extend API to handle the new event
      * src/qemu/qemu_driver.c: Connect to the QEMU monitor event
        for block_stream completion and emit a libvirt block pull event
      * src/remote/remote_driver.c: Receive and dispatch events to application
      * src/remote/remote_protocol.x: Wire protocol definition for the event
      * src/remote_protocol-structs: structure definitions for protocol verification
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
        src/qemu/qemu_monitor_json.c: Watch for BLOCK_STREAM_COMPLETED event
        from QEMU monitor
      d489b046
    • A
      Implement virDomainBlockPull for the qemu driver · b976165c
      Adam Litke 提交于
      The virDomainBlockPull* family of commands are enabled by the
      following HMP/QMP commands: 'block_stream', 'block_job_cancel',
       'info block-jobs' / 'query-block-jobs', and 'block_job_set_speed'.
      
      * src/qemu/qemu_driver.c src/qemu/qemu_monitor_text.[ch]: implement disk
        streaming by using the proper qemu monitor commands.
      * src/qemu/qemu_monitor_json.[ch]: implement commands using the qmp monitor
      b976165c
    • A
      Add virDomainBlockPull support to the remote driver · 4daeefac
      Adam Litke 提交于
      The generator can handle everything except virDomainGetBlockJobInfo().
      
      * src/remote/remote_protocol.x: provide defines for the new entry points
      * src/remote/remote_driver.c daemon/remote.c: implement the client and
        server side for virDomainGetBlockJobInfo.
      * src/remote_protocol-structs: structure definitions for protocol verification
      * src/rpc/gendispatch.pl: Permit some unsigned long parameters
      4daeefac
    • A
      virDomainBlockPull: Implement the main entry points · 72082a05
      Adam Litke 提交于
      * src/libvirt.c: implement the main entry points
      72082a05
    • A
      Add new API virDomainBlockPull* to headers · 152e8103
      Adam Litke 提交于
      Set up the types for the block pull functions and insert them into the
      virDriver structure definition.  Symbols are exported in this patch to
      prevent
      documentation compile failures.
      
      * include/libvirt/libvirt.h.in: new API
      * src/driver.h: add the new entry to the driver structure
      * python/generator.py: fix compiler errors, the actual python bindings
      * are
        implemented later
      * src/libvirt_public.syms: export symbols
      * docs/apibuild.py: Extend 'unsigned long' parameter exception to this
      * API
      152e8103
    • E
      save: wire up remote protocol · 0696beca
      Eric Blake 提交于
      * src/remote/remote_driver.c (remote_driver): Add new callbacks.
      * src/remote/remote_protocol.x (remote_procedure): New RPCs.
      (remote_domain_save_image_get_xml_desc_args)
      (remote_domain_save_image_get_xml_desc_ret)
      (remote_domain_save_image_define_xml_args): New structs.
      * src/remote_protocol-structs: Update.
      0696beca
    • E
      save: new API to manipulate save file images · d2a929d4
      Eric Blake 提交于
      Modifying the xml on either save or restore only gets you so
      far - you have to remember to 'virsh dumpxml dom' just prior
      to the 'virsh save' in order to have an xml file worth modifying
      that won't be rejected due to abi breaks.  To make this more
      powerful, we need a way to grab the xml embedded within a state
      file, and from there, it's not much harder to also support
      modifying a state file in-place.
      
      Also, virDomainGetXMLDesc didn't document its flags.
      
      * include/libvirt/libvirt.h.in (virDomainSaveImageGetXMLDesc)
      (virDomainSaveImageDefineXML): New prototypes.
      * src/libvirt.c (virDomainSaveImageGetXMLDesc)
      (virDomainSaveImageDefineXML): New API.
      * src/libvirt_public.syms: Export them.
      * src/driver.h (virDrvDomainSaveImageGetXMLDesc)
      (virDrvDomainSaveImgeDefineXML): New driver callbacks.
      d2a929d4
    • E
      save: support bypass-cache flag in qemu.conf · a9f9545e
      Eric Blake 提交于
      When auto-dumping a domain on crash events, or autostarting a domain
      with managed save state, let the user configure whether to imply
      the bypass cache flag.
      
      * src/qemu/qemu.conf (auto_dump_bypass_cache, auto_start_bypass_cache):
      Document new variables.
      * src/qemu/libvirtd_qemu.aug (vnc_entry): Let augeas parse them.
      * src/qemu/qemu_conf.h (qemud_driver): Store new preferences.
      * src/qemu/qemu_conf.c (qemudLoadDriverConfig): Parse them.
      * src/qemu/qemu_driver.c (processWatchdogEvent, qemuAutostartDomain):
      Honor them.
      a9f9545e
    • E
      save: support BYPASS_CACHE during qemu save/restore · 58e668d2
      Eric Blake 提交于
      Wire together the previous patches to support file system cache
      bypass during API save/restore requests in qemu.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal, doCoreDump)
      (qemudDomainObjStart, qemuDomainSaveImageOpen, qemuDomainObjRestore)
      (qemuDomainObjStart): Add parameter.
      (qemuDomainSaveFlags, qemuDomainManagedSave, qemudDomainCoreDump)
      (processWatchdogEvent, qemudDomainStartWithFlags, qemuAutostartDomain)
      (qemuDomainRestoreFlags): Update callers.
      58e668d2
    • E
      save: add virFileDirectFd wrapper type · 519a1c43
      Eric Blake 提交于
      O_DIRECT has stringent requirements.  Rather than make lots of changes
      at each site that wants to use O_DIRECT, it is easier to offload
      the work through a helper process that mirrors the I/O between a
      pipe and the actual direct fd, so that the other end of the pipe
      no longer has to worry about constraints.
      
      Plus, if the kernel ever gains better posix_fadvise support, then we
      only have to touch a single file to let all callers benefit from a
      more efficient way to avoid file system caching.
      
      * src/util/virfile.h (virFileDirectFdFlag, virFileDirectFdNew)
      (virFileDirectFdClose, virFileDirectFdFree): New prototypes.
      * src/util/virdirect.c: Implement new wrapper object.
      * src/libvirt_private.syms (virfile.h): Export new symbols.
      * cfg.mk (useless_free_options): Add to list.
      * po/POTFILES.in: Add new translations.
      519a1c43
    • E
      save: let iohelper work on O_DIRECT fds · 12291656
      Eric Blake 提交于
      Required for a coming patch where iohelper will operate on O_DIRECT
      fds.  There, the user-space memory must be aligned to file system
      boundaries (at least 512, but using page-aligned works better, and
      some file systems prefer 64k).  Made tougher by the fact that
      VIR_ALLOC won't work on void *, but posix_memalign won't work on
      char * and isn't available everywhere.
      
      This patch makes some simplifying assumptions - namely, output
      to an O_DIRECT fd will only be attempted on an empty seekable
      file (hence, no need to worry about preserving existing data
      on a partial block, and ftruncate will work to undo the effects
      of having to round up the size of the last block written), and
      input from an O_DIRECT fd will only be attempted on a complete
      seekable file with the only possible short read at EOF.
      
      * configure.ac (AC_CHECK_FUNCS_ONCE): Check for posix_memalign.
      * src/util/iohelper.c (runIO): Use aligned memory, and handle
      quirks of O_DIRECT on last write.
      12291656
    • E
      save: let iohelper handle inherited fd · 1eb66479
      Eric Blake 提交于
      Rather than making the iohelper subject to a race in reopening
      the file, it is nicer to pass an already-open fd by inheritance.
      
      The old synopsis form must continue to work - if someone updates
      their libvirt package and installs a new libvirt_iohelper but
      without restarting the old libvirtd daemon, then the daemon can
      still make calls using the old syntax but the new iohelper.
      
      * src/util/iohelper.c (runIO): Split code for open...
      (prepare): ...to new function.
      (usage): Update synopsis.
      (main): Allow alternate calling form.
      * src/fdstream.c (virFDStreamOpenFileInternal): Use alternate form.
      1eb66479
    • E
      save: wire up trivial save/restore flags implementations · b1083a4c
      Eric Blake 提交于
      For all hypervisors that support save and restore, the new API
      now performs the same functions as the old.
      
      VBox is excluded from this list, because its existing domainsave
      is broken (there is no corresponding domainrestore, and there
      is no control over the filename used in the save).  A later
      patch should change vbox to use its implementation for
      managedsave, and teach start to use managedsave results.
      
      * src/libxl/libxl_driver.c (libxlDomainSave): Move guts...
      (libxlDomainSaveFlags): ...to new function.
      (libxlDomainRestore): Move guts...
      (libxlDomainRestoreFlags): ...to new function.
      * src/test/test_driver.c (testDomainSave, testDomainSaveFlags)
      (testDomainRestore, testDomainRestoreFlags): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainSave)
      (xenUnifiedDomainSaveFlags, xenUnifiedDomainRestore)
      (xenUnifiedDomainRestoreFlags): Likewise.
      * src/qemu/qemu_driver.c (qemudDomainSave, qemudDomainRestore):
      Rename and move guts.
      (qemuDomainSave, qemuDomainSaveFlags, qemuDomainRestore)
      (qemuDomainRestoreFlags): ...here.
      (qemudDomainSaveFlag): Rename...
      (qemuDomainSaveInternal): ...to this, and update callers.
      b1083a4c
    • E
      error: add new error type for reflecting partial API support · 17003457
      Eric Blake 提交于
      VIR_ERR_INVALID_ARG implies that an argument cannot possibly
      be correct, given the current state of the API.
      VIR_ERR_CONFIG_UNSUPPORTED implies that a configuration is
      wrong, but arguments aren't configuration.
      VIR_ERR_NO_SUPPORT implies that a function is completely
      unimplemented.
      
      But in the case of a function that is partially implemented,
      yet the full power of the API is not available for that
      driver, none of the above messages make sense.  Hence a new
      error message, implying that the argument is known to comply
      with the current state of the API, and that while the driver
      supports aspects of the function, it does not support that
      particular use of the argument.
      
      A good use case for this is a driver that supports
      virDomainSaveFlags, but not the dxml argument of that API.
      
      It might be feasible to also use this new error for all functions
      that check flags, and which accept fewer flags than what is possible
      in the public API.  But doing so would get complicated, since
      neither libvirt.c nor the remote driver may do flag filtering,
      and every other driver would have to do a two-part check, first
      using virCheckFlags on all public flags (which gives
      VIR_ERR_INVALID_ARG for an impossible flag), followed by a
      particular mask check for VIR_ERR_ARGUMENT_UNSUPPORTED (for a
      possible public flag but unsupported by this driver).
      
      * include/libvirt/virterror.h (VIR_ERR_ARGUMENT_UNSUPPORTED): New
      error.
      * src/util/virterror.c (virErrorMsg): Give it a message.
      Suggested by Daniel P. Berrange.
      17003457
    • E
      build: fix bugs with destroyFlags patches · 934fdcb3
      Eric Blake 提交于
      Build failure on xenapi_driver from compiler warnings (flags was unused).
      
      Build failure on xen (incorrect number of arguments).  And in fixing
      that, I obeyed the comments of struct xenUnifiedDriver that state
      that we want to minimize the number of callback functions in that
      struct, not add to it.
      
      * src/xen/xen_driver.c (xenUnifiedDomainDestroyFlags): Use correct
      arguments.
      (xenUnifiedDomainDestroy): Simplify.
      * src/xen/xen_driver.h (xenUnifiedDriver): Remove unused callback.
      * src/xen/xen_hypervisor.c (xenHypervisorDestroyDomain): Likewise.
      * src/xen/xend_internal.c (xenDaemonDomainDestroy): Likewise.
      * src/xen/xend_internal.h (xenDaemonDomainDestroyFlags): Likewise.
      * src/xen/xm_internal.c (xenXMDriver): Likewise.
      * src/xen/xs_internal.c (xenStoreDriver): Likewise.
      * src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
      * src/xenapi/xenapi_driver.c (xenapiDomainDestroyFlags): Reject
      unknown flags.
      934fdcb3
    • M
      remote: Fix forgotten comma · a9135359
      Michal Privoznik 提交于
      during conflict resolving
      a9135359
    • L
      network: internal API functions to manage assignment of physdev to guest · 04711a0f
      Laine Stump 提交于
      The network driver needs to assign physical devices for use by modes
      that use macvtap, keeping track of which physical devices are in use
      (and how many instances, when the devices can be shared). Three calls
      are added:
      
      networkAllocateActualDevice - finds a physical device for use by the
      domain, and sets up the virDomainActualNetDef accordingly.
      
      networkNotifyActualDevice - assumes that the domain was already
      running, but libvirtd was restarted, and needs to be notified by each
      already-running domain about what interfaces they are using.
      
      networkReleaseActualDevice - decrements the usage count of the
      allocated physical device, and frees the virDomainActualNetDef to
      avoid later accidentally using the device.
      
      bridge_driver.[hc] - the new APIs. When WITH_NETWORK is false, these
      functions are all #defined to be "0" in the .h file (effectively
      becoming a NOP) to prevent link errors.
      
      qemu_(command|driver|hotplug|process).c - add calls to the above APIs
          in the appropriate places.
      
      tests/Makefile.am - we need to include libvirt_driver_network.la
          whenever libvirt_driver_qemu.la is linked, to avoid unreferenced
          symbols (in functions that are never called by the test
          programs...)
      04711a0f
    • L
      qemu: use virDomainNetGetActual*() in qemuDomainXMLToNative · e9949a58
      Laine Stump 提交于
      This is the one function outside of domain_conf.c that plays around
      with (even modifying) the internals of the virDomainNetDef, and thus
      can't be fixed up simply by replacing direct accesses to the fields of
      the struct with the GetActual*() access functions.
      
      In this case, we need to check if the defined type is "network", and
      if it is *then* check the actual type; if the actual type is "bridge",
      then we can at least put the bridgename in a place where it can be
      used; otherwise (if type isn't "bridge"), we behave exactly as we used
      to - just null out *everything*.
      e9949a58
    • L
      qemu: use virDomainNetGetActual*() functions where appropriate · 03caa988
      Laine Stump 提交于
      The qemu driver accesses fields in the virDomainNetDef directly, but
      with the advent of the virDomainActualNetDef, some pieces of
      information may be found in a different place (the ActualNetDef) if
      the network connection is of type='network' and that network is of
      forward type='bridge|private|vepa|passthrough'. The previous patch
      added functions to mask this difference from callers - they hide the
      decision making process and just pick the value from the proper place.
      
      This patch uses those functions in the qemu driver as a first step in
      making qemu work with the new network types. At this point, the
      virDomainActualNetDef is guaranteed always NULL, so the GetActualX()
      function will return exactly what the def->X that's being replaced
      would have returned (ie bisecting is not compromised).
      
      There is one place (in qemu_driver.c) where the internal details of
      the NetDef are directly manipulated by the code, so the GetActual
      functions cannot be used there without extra additional code; that
      file will be treated in a separate patch.
      03caa988
    • L
      network: separate Start/Shutdown functions for new network types · b48e81bf
      Laine Stump 提交于
      Previously all networks were composed of bridge devices created and
      managed by libvirt, and the same operations needed to be done for all
      of them when they were started and stopped (create and start the
      bridge device, configure its MAC address and IP address, add iptables
      rules). The new network types are (for now at least) managed outside
      of libvirt, and the network object is used only to contain information
      about the network, which is then used as each individual guest
      connects itself.
      
      This means that when starting/stopping one of these new networks, we
      really want to do nothing, aside from marking the network as
      active/inactive.
      
      This has been setup as toplevel Start/Shutdown functions that do the
      small bit of common stuff, then have a switch statement to execute
      network type-specific start/shutdown code, then do a bit more common
      code. The type-specific functions called for the new host bridge and
      macvtap based types are currently empty.
      
      In the future these functions may actually do something, and we will
      surely add more functions that are similarly patterned. Once
      everything has settled, we can make a table of "sub-driver" function
      pointers for each network type, and store a pointer to that table in
      the network object, then we can replace the switch statements with
      calls to functions in the table.
      
      The final step in this will be to add a new table (and corresponding
      new functions) for new network types as they are added.
      b48e81bf
    • L
      conf: support abstracted interface info in network XML · 40fd7073
      Laine Stump 提交于
      The network XML is updated in the following ways:
      
      1) The <forward> element can now contain a list of forward interfaces:
      
           <forward .... >
             <interface dev='eth10'/>
             <interface dev='eth11'/>
             <interface dev='eth12'/>
             <interface dev='eth13'/>
           </forward>
      
         The first of these takes the place of the dev attribute that is
         normally in <forward> - when defining a network you can specify
         either one, and on output both will be present. If you specify
         both on input, they must match.
      
      2) In addition to forward modes of 'nat' and 'route', these new modes
         are supported:
      
           private, passthrough, vepa - when this network is referenced by a
           domain's interface, it will have the same effect as if the
           interface had been defined as type='direct', e.g.:
      
              <interface type='direct'>
                <source mode='${mode}' dev='${dev}>
                ...
              </interface>
      
           where ${mode} is one of the three new modes, and ${dev} is an interface
           selected from the list given in <forward>.
      
           bridge - if a <forward> dev (or multiple devs) is defined, and
           forward mode is 'bridge' this is just like the modes 'private',
           'passthrough', and 'vepa' above. If there is no forward dev
           specified but a bridge name is given (e.g. "<bridge
           name='br0'/>"), then guest interfaces using this network will use
           libvirt's "host bridge" mode, equivalent to this:
      
             <interface type='bridge'>
                <source bridge='${bridge-name}'/>
                ...
             </interface>
      
      3) A network can have multiple <portgroup> elements, which may be
         selected by the guest interface definition (by adding
         "portgroup='${name}'" in the <source> element along with the
         network name). Currently a portgroup can only contain a
         virtportprofile, but the intent is that other configuration items
         may be put there int the future (e.g. bandwidth config). When
         building a guest's interface, if the <interface> XML itself has no
         virtportprofile, and if the requested network has a portgroup with
         a name matching the name given in the <interface> (or if one of the
         network's portgroups is marked with the "default='yes'" attribute),
         the virtportprofile from that portgroup will be used by the
         interface.
      
      4) A network can have a virtportprofile defined at the top level,
         which will be used by a guest interface when connecting in one of
         the 'direct' modes if the guest interface XML itself hasn't
         specified any virtportprofile, and if there are also no matching
         portgroups on the network.
      40fd7073
    • L
      conf: support abstracted interface info in domain interface XML · 07f41369
      Laine Stump 提交于
      the domain XML <interface> element is updated in the following ways:
      
      1) <virtualportprofile> can be specified when source type='network'
      (previously it was only valid for source type='direct')
      
      2) A new attribute "portgroup" has been added to the <source>
      element. When source type='network' (the only time portgroup is
      recognized), extra configuration information will be taken from the
      <portgroup> element of the given name in the network definition.
      
      3) Each virDomainNetDef now also potentially has a
      virDomainActualNetDef which is a private object (never
      exported/imported via the public API, and not defined in the RNG) that
      is used to maintain information about the physical device that was
      actually used for a NetDef of type VIR_DOMAIN_NET_TYPE_NETWORK.
      
      The virDomainActualNetDef will only be parsed/formatted if the
      parse/format function is called with the
      VIR_DOMAIN_XML_INTERNAL_ACTUAL_NET flag set (which is only needed when
      saving/loading a running domain's state info to the stateDir).
      07f41369
    • L
      conf: virDomainNetDef points to (rather than contains) virtPortProfile · 524655ee
      Laine Stump 提交于
      The virtPortProfile in the domain interface struct is now a separately
      allocated object *pointed to by* (rather than contained in) the main
      virDomainNetDef object. This is done to make it easier to figure out
      when a virtualPortProfile has/hasn't been specified in a particular
      config.
      524655ee
    • L
      conf: put virtPortProfile struct / functions in a common location · a3d95b55
      Laine Stump 提交于
      virtPortProfiles are currently only used in the domain XML, but will
      soon also be used in the network XML. To prepare for that change, this
      patch moves the structure definition into util/network.h and the parse
      and format functions into util/network.c (I decided that this was a
      better choice than macvtap.h/c for something that needed to always be
      available on all platforms).
      a3d95b55
    • L
      util: define MAX · 6fe5fde2
      Laine Stump 提交于
      If util.h is going to have a MIN, it may as well also have MAX.
      6fe5fde2
    • M
      7b5fc597
    • M
      destroy: Implement internal API for xen driver · 1edf5cc5
      Michal Privoznik 提交于
      1edf5cc5
    • M
      73838d33
    • M
      destroy: Implement internal API for vbox driver · 6ec7195c
      Michal Privoznik 提交于
      6ec7195c
    • M
      destroy: Implement internal API for uml driver · 64ce43f8
      Michal Privoznik 提交于
      64ce43f8
    • M
      destroy: Implement internal API for phyp driver · e4e69b4b
      Michal Privoznik 提交于
      e4e69b4b
    • M
      ab5eb92b
    • M
      destroy: Implement internal API for lxc driver · 2dd3f025
      Michal Privoznik 提交于
      2dd3f025
    • M
      destroy: Implement internal API for libxl driver · ba0219a7
      Michal Privoznik 提交于
      ba0219a7
    • M
      destroy: Implement internal API for ESX driver · 3959fe30
      Michal Privoznik 提交于
      3959fe30