1. 24 6月, 2011 4 次提交
    • D
      Fix job type set in qemuMigrationPrepareDirect/PrepareTunnel · 74798313
      Daniel P. Berrange 提交于
      The qemuMigrationPrepareDirect/PrepareTunnel methods accidentally
      set the domain job to  QEMU_JOB_MIGRATION_OUT when it should have
      been  QEMU_JOB_MIGRATION_IN. This didn't have any ill-effect, but
      it is none-the-less wrong.
      
      * src/qemu/qemu_migration.c: Fix job type
      74798313
    • D
      Allow automatic kill of guests when a connection is closed · 3ba937da
      Daniel P. Berrange 提交于
      If an application is using libvirt + KVM as a piece of its
      internal infrastructure to perform a specific task, it can
      be desirable to guarentee the VM dies when the virConnectPtr
      disconnects from libvirtd. This ensures the app can't leak
      any VMs it was using. Adding VIR_DOMAIN_START_AUTOKILL as
      a flag when starting guests enables this to be done.
      
      * include/libvirt/libvirt.h.in: All VIR_DOMAIN_START_AUTOKILL
      * src/qemu/qemu_driver.c: Support automatic killing of guests
        upon connection close
      * tools/virsh.c: Add --autokill flag to 'start' and 'create'
        commands
      3ba937da
    • D
      Automatically kill target QEMU if migration aborts abnormally · 2c2effa1
      Daniel P. Berrange 提交于
      Migration is a multi-step process
      
        1. Begin(src)
        2. Prepare(dst)
        3. Perform(src)
        4. Finish(dst)
        5. Confirm(src)
      
      At step 2, a QEMU process is lauched in the destination to
      accept the incoming migration. Occasionally the process
      that is controlling the migration workflow aborts, and fails
      to call step 4, Finish. This leaves a QEMU process running
      on the target (albeit with paused CPUs). Unfortunately because
      step 2 actives a job on the QEMU process, it is unkillable by
      normal means.
      
      By registering the VM for autokill against the src virConnectPtr
      in step 2, we can ensure that the guest is forcefully killed off
      if the connection is closed without step 4 being invoked
      
      * src/qemu/qemu_migration.c: Register autokill in PrepareDirect
        and PrepareTunnel. Unregister autokill on successful run
        of Finish
      * src/qemu/qemu_process.c: Unregister autokill when stopping a
        process
      2c2effa1
    • D
      Add infrastructure to automatically destroy guests when a connection closes · 558b7fd0
      Daniel P. Berrange 提交于
      Sometimes it is useful to be able to automatically destroy a guest when
      a connection is closed. For example, kill an incoming migration if
      the client managing the migration dies. This introduces a map between
      guest 'uuid' strings and virConnectPtr objects. When a connection is
      closed, any associated guests are killed off.
      
      * src/qemu/qemu_conf.h: Add autokill hash table to qemu driver
      * src/qemu/qemu_process.c, src/qemu/qemu_process.h: Add APIs
        for performing autokill of guests associated with a connection
      * src/qemu/qemu_driver.c: Initialize autodestroy map
      558b7fd0
  2. 13 6月, 2011 1 次提交
  3. 06 6月, 2011 1 次提交
    • D
      Fix QEMU p2p v2 migration when run from a v3 client · 3e87a390
      Daniel P. Berrange 提交于
      When peer-2-peer migration was invoked by a client supporting
      v3, but where the target server only supported v2, we'd not
      correctly shutdown the guest.
      
      * src/qemu/qemu_migration.c: Ensure guest is shutdown in
        v2 peer 2 peer migration
      3e87a390
  4. 04 6月, 2011 1 次提交
  5. 03 6月, 2011 1 次提交
    • D
      Explicitly set VM state to paused after migration completes · 6d68e0df
      Daniel P. Berrange 提交于
      In v3 migration, once migration is completed, the VM needs
      to be left in a paused state until after Finish3 has been
      executed on the target. Only then will the VM be killed
      off. When using non-JSON QEMU monitor though, we don't
      receive any 'STOP' event from QEMU, so we need to manually
      set our state offline & thus release lock manager leases.
      It doesn't hurt to run this on the JSON case too, just in
      case the event gets lost somehow
      
      * src/qemu/qemu_migration.c: Explicitly set VM state to
        paused when migration completes
      6d68e0df
  6. 02 6月, 2011 1 次提交
    • D
      Support passing QEMU lock state to dest during migration · 7474560b
      Daniel P. Berrange 提交于
      Some lock managers associate state with leases, allowing a process
      to temporarily release its leases, and re-acquire them later, safe
      in the knowledge that no other process has acquired + released the
      leases in between.
      
      This is already used between suspend/resume operations, and must
      also be used across migration. This passes the lockstate in the
      migration cookie. If the lock manager uses lockstate, then it
      becomes compulsory to use the migration v3 protocol to get the
      cookie support.
      
      * src/qemu/qemu_driver.c: Validate that migration v2 protocol is
        not used if lock manager needs state transfer
      * src/qemu/qemu_migration.c: Transfer lock state in migration
        cookie XML
      7474560b
  7. 31 5月, 2011 1 次提交
    • D
      Allow custom XML to be passed in during migration · 44924615
      Daniel P. Berrange 提交于
      Update the qemuDomainMigrateBegin method so that it accepts
      an optional incoming XML document. This will be validated
      for ABI compatibility against the current domain config,
      and if this check passes, will be passed back out for use
      by the qemuDomainMigratePrepare method on the target
      
      * src/qemu/qemu_domain.c, src/qemu/qemu_domain.h,
        src/qemu/qemu_migration.c: Allow custom XML to be passed
      44924615
  8. 27 5月, 2011 1 次提交
    • F
      qemu: allow blkstat/blkinfo calls during migration · 18c2a592
      Federico Simoncelli 提交于
      Originally most of libvirt domain-specific calls were blocking
      during a migration.
      A new mechanism to allow specific calls (blkstat/blkinfo) to be
      executed in such condition has been implemented.
      In the long term it'd be desirable to get a more general
      solution to mark further APIs as migration safe, without needing
      special case code.
      
       * src/qemu/qemu_migration.c: add some additional job signal
         flags for doing blkstat/blkinfo during a migration
       * src/qemu/qemu_domain.c: add a condition variable that can be
         used to efficiently wait for the migration code to clear the
         signal flag
       * src/qemu/qemu_driver.c: execute blkstat/blkinfo using the
         job signal flags during migration
      18c2a592
  9. 25 5月, 2011 8 次提交
    • D
      Fix the signature of virDomainMigrateFinish3 for error reporting · 2593f969
      Daniel P. Berrange 提交于
      The current virDomainMigrateFinish3 method signature attempts to
      distinguish two types of errors, by allowing return with ret== 0,
      but ddomain == NULL, to indicate a failure to start the guest.
      This is flawed, because when ret == 0, there is no way for the
      virErrorPtr details to be sent back to the client.
      
      Change the signature of virDomainMigrateFinish3 so it simply
      returns a virDomainPtr, in the same way as virDomainMigrateFinish2
      The disk locking code will protect against the only possible
      failure mode this doesn't account for (loosing conenctivity to
      libvirtd after Finish3 starts the CPUs, but before the client
      sees the reply for Finish3).
      
      * src/driver.h, src/libvirt.c, src/libvirt_internal.h: Change
        virDomainMigrateFinish3 to return a virDomainPtr instead of int
      * src/remote/remote_driver.c, src/remote/remote_protocol.x,
        daemon/remote.c, src/qemu/qemu_driver.c, src/qemu/qemu_migration.c:
        Update for API change
      2593f969
    • D
      Fix preservation of errors across migration steps · 5e31df93
      Daniel P. Berrange 提交于
      When doing migration, if an error occurs in Perform, it must not
      be overwritten during Finish/Confirm steps. If an error occurs
      in Finish, it must not be overwritten in Confirm.
      
      Previous commit a9d12c24 added
      code to qemudDomainMigrateFinish2 to preserve the error. This
      is not the right place, because it is not applicable in non-p2p
      migration. The src/libvirt.c virDomainMigrateV2/3 methods need
      code to preserve errors for non-p2p migration, while the
      doPeer2PeerMigrate2 and doPeer2PeerMigrate3 methods contain
      code to preverse errors for p2p migration.
      
      Remove the bogus error preservation from qemudDomainMigrateFinish2
      and qemudDomainMigrateFinish3.
      
      Fix virDomainMigrateV3 and doPeer2PeerMigrate3 so that they
      preserve any error hit during the Finish3 step, before invoking
      Confirm3.
      
      Finally if qemuMigrationFinish fails to resume the CPUs, it must
      preserve the error before tearing down the VM, so that VM cleanup
      doesn't overwrite it.
      
      * src/libvirt.c: Preserve error before invoking Confirm3
      * src/qemu/qemu_driver.c: Remove bogus error preservation
        code in qemudDomainMigrateFinish2/qemudDomainMigrateFinish3
      * src/qemu/qemu_migration.c: Preserve error before invoking Confirm3
        and after resume fails in qemuMigrationFinish.
      5e31df93
    • D
      Improve debug logging of migration APIs · 03547eee
      Daniel P. Berrange 提交于
      * src/libvirt.c: Add further debug lines in helper APIs for
        migration
      * src/qemu/qemu_migration.c: Add debug lines for all internal
        migration API parameters
      03547eee
    • D
      Fix error propagation in finish method for v3 migration · 1853bd9d
      Daniel P. Berrange 提交于
      Even when failing to start CPUs, the finish method was returning
      a success result. Fix this so that the QEMU process is killed
      off when finish fails under v3 protocol. Also rename the
      killOnFinish boolean to 'v3proto' to make it clearer that this
      is a tunable based on the migration protocol version
      
      * src/qemu/qemu_driver.c: Update for API change
      * src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Kill
        VM in qemuMigrationFinish if failing to start CPUs
      1853bd9d
    • D
      Fix SPICE seamless migration hostname · b3367103
      Daniel P. Berrange 提交于
      The SPICE seamless migration process requires data to be passed
      back from the target host, to the source host via a cookie.
      The cookie includes the target host's hostname, but this was not
      stored, merely validated. This patch explicitly records the
      remote hostname after parsing the cookie, and uses it when
      initiating the SPICE migration
      
      * qemu/qemu_migration.c: Fix SPICE seamless migration hostname
      b3367103
    • D
      Fix resume on destination when doing non-live tunnelled migration · 73b3e0b7
      Daniel P. Berrange 提交于
      Before running perform in peer-2-peer migration, the current
      guest state must be recorded, so that non-live migration can
      currently unpause a running guest on completion.
      
      * src/qemu/qemu_migration.c: Move check for offline guest
        to fix non-live migration
      73b3e0b7
    • D
      Add a second URI parameter to virDomainMigratePerform3 method · f9f2d4e1
      Daniel P. Berrange 提交于
      The virDomainMigratePerform3 currently has a single URI parameter
      whose meaning varies. It is either
      
       - A QEMU migration URI (normal migration)
       - A libvirtd connection URI (peer2peer migration)
      
      Unfortunately when using peer2peer migration, without also
      using tunnelled migration, it is possible that both URIs are
      required.
      
      This adds a second URI parameter to the virDomainMigratePerform3
      method, to cope with this scenario. Each parameter how has a fixed
      meaning.
      
      NB, there is no way to actually take advantage of this yet,
      since virDomainMigrate/virDomainMigrateToURI do not have any
      way to provide the 2 separate URIs
      
      * daemon/remote.c, src/remote/remote_driver.c,
        src/remote/remote_protocol.x, src/remote_protocol-structs: Add
        the second URI parameter to perform3 message
      * src/driver.h, src/libvirt.c, src/libvirt_internal.h: Add
        the second URI parameter to Perform3 method
      * src/libvirt_internal.h, src/qemu/qemu_migration.c,
        src/qemu/qemu_migration.h: Update to handle URIs correctly
      f9f2d4e1
    • D
      Extend v3 migration protocol to allow app supplied XML for target · 7ad4b6b9
      Daniel P. Berrange 提交于
      This extends the v3 migration protocol such that the
      virDomainMigrateBegin3 and virDomainMigratePerform3
      methods accept an application supplied XML config for
      the target VM.
      
      If the 'xmlin' parameter is NULL, then Begin3 uses the
      current guest XML as normal. A driver implementing the
      Begin3 method should either reject all non-NULL 'xmlin'
      parameters, or strictly validate that the app supplied
      XML does not change guest ABI.
      
      The Perform3 method also needed the xmlin parameter to
      cope with the Peer2Peer migration sequence.
      
      NB it is not yet possible to use this capability since
      neither of the public virDomainMigrate/virDomainMigrateToURI
      methods have a way to pass in XML.
      
      * daemon/remote.c, src/remote/remote_driver.c,
        src/remote/remote_protocol.x, src/remote_protocol-structs:
        Add 'remote_string xmlin' parameter to begin3/perform3
        RPC messages
      * src/libvirt.c, src/driver.h, src/libvirt_internal.h: Add
        'const char *xmlin' parameter to Begin3/Perform3 methods
      * src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
        src/qemu/qemu_migration.h: Pass xmlin parameter around
        migration methods
      7ad4b6b9
  10. 24 5月, 2011 2 次提交
    • D
      Fix peer2peer migration with transient VMs · 65e1acad
      Daniel P. Berrange 提交于
      The qemuMigrationConfirm method shouldn't deal with final VM
      cleanup, since it can be called from the peer2peer migration,
      which expects to still use the 'vm' object afterwards.
      
      Push the cleanup code out of qemuMigrationConfirm, into its
      caller, qemuDomainMigrateConfirm3
      
      * src/qemu/qemu_driver.c: Add VM cleanup code to
        qemuDomainMigrateConfirm3
      * src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Remove
        job handling cleanup from qemuMigrationConfirm
      65e1acad
    • D
      Perform feature flag compat checking in QEMU migration cookies · f88af9dc
      Daniel P. Berrange 提交于
      To allow new mandatory migration cookie data to be introduced,
      add support for checking supported feature flags when parsing
      migration cookie.
      
      * src/qemu/qemu_migration.c: Feature flag checking in migration
        cookie parsing
      f88af9dc
  11. 19 5月, 2011 1 次提交
    • D
      Fix QEMU migration cookie crash for guests with no graphics · 03f88326
      Daniel P. Berrange 提交于
      When generating a cookie for a guest with no data, the
      QEMU_MIGRATION_COOKIE_GRAPHICS flag was set even if no
      graphics data was added. Avoid setting the flag unless
      it was needed, also add a safety check for mig->graphics
      being non-NULL
      
      * src/qemu/qemu_migration.c: Avoid cookie crash for guest
        with no graphics
      03f88326
  12. 18 5月, 2011 1 次提交
  13. 16 5月, 2011 15 次提交
    • D
      Add missing initialization to 'ret' in qemu migration · 6e7c56f8
      Daniel P. Berrange 提交于
      * src/qemu/qemu_migration.c: Add missing 'ret' initializer
        in qemuMigrationCookieXMLParseStr
      6e7c56f8
    • D
      Run tunnelled migration IO in separate thread · 1d916a60
      Daniel P. Berrange 提交于
      By running the doTunnelSendAll code in a separate thread, the
      main thread can do qemuMigrationWaitForCompletion as with
      normal migration. This in turn ensures that job signals work
      correctly and that progress monitoring can be done
      
      * src/qemu/qemu_migration.c: Run tunnelled migration in
        separate thread
      1d916a60
    • D
      Don't overwrite error when stream send fails · 5a6ca96a
      Daniel P. Berrange 提交于
      virStreamSend already sets an error message, so don't
      overwrite it
      
      * src/qemu/qemu_migration.c: Remove bogus error report
      5a6ca96a
    • D
      Close all sockets before cancelling QEMU migration · 2bf92bb8
      Daniel P. Berrange 提交于
      Cancelling the QEMU migration may cause QEMU to flush pending
      data on the migration socket. This may in turn block QEMU if
      nothing reads from the other end of the socket. Closing the
      socket before cancelling QEMU migration avoids this possible
      deadlock.
      
      * src/qemu/qemu_migration.c: Close sockets before cancelling
        migration on failure
      2bf92bb8
    • D
      Ensure we always read a full buffer in tunnelled migration · 74f33246
      Daniel P. Berrange 提交于
      The 'nbytes' variable was not re-initialized to the
      buffer size on each iteration of the tunnelled migration
      loop. While saferead() will ensure a full read, except
      on EOF, it is clearer to use the real buffer size
      
      * src/qemu/qemu_migration.c: Always read full buffer of data
      74f33246
    • D
      Make tunnelled migration honour resource restriction · dba5a604
      Daniel P. Berrange 提交于
      The doTunnelMigrate method forgot to set the bandwidth
      resource restriction
      
      * src/qemu/qemu_migration.c: Set resource restriction
      dba5a604
    • D
      Refactor migration completion loop to allow code reuse · 792a5a61
      Daniel P. Berrange 提交于
      The qemuMigrationWaitForCompletion method contains a loop which
      repeatedly queries QEMU to check migration progress, and also
      processes job signals (pause, setspeed, setbandwidth, cancel).
      
      The tunnelled migration loop does not currently support this
      functionality, but should. Refactor the code to allow it to
      be used with tunnelled migration.
      792a5a61
    • D
      Implement migration v3 protocol in QEMU driver · 2d5caf7a
      Daniel P. Berrange 提交于
      Implement the v3 migration protocol, which has two extra
      steps, 'begin' on the source host and 'confirm' on the
      source host. All other methods also gain both input and
      output cookies to allow bi-directional data passing at
      all stages.
      
      The QEMU peer2peer migration method gains another impl
      to provide the v3 migration. This finally allows migration
      cookies to work with tunnelled migration, which is required
      for Spice seamless migration & the lock manager transfer
      
      * src/qemu/qemu_driver.c: Wire up migrate v3 APIs
      * src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Add
        begin & confirm methods, and peer2peer impl of v3
      2d5caf7a
    • D
      Merge tunnel & non-tunnel migration impl into one · 636ee926
      Daniel P. Berrange 提交于
      Merge the doNonTunnelMigrate2 and doTunnelMigrate2 methods
      into one doPeer2PeerMigrate2 method, since they are substantially
      the same. With the introduction of v3 migration, this will be
      even more important, to avoid massive code duplication.
      
      * src/qemu/qemu_migration.c: Merge tunnel & non-tunnel migration
      636ee926
    • D
      Refactor tunnelled migration methods · 13cb49f8
      Daniel P. Berrange 提交于
      To facilitate the introduction of the v3 migration protocol,
      the doTunnelMigrate method is refactored into two pieces. One
      piece is intended to mirror the flow of virDomainMigrateVersion2,
      while the other is the helper for setting up sockets and processing
      the data.
      
      Previously socket setup would be done before the 'prepare' step,
      so errors could be dealt with immediately, avoiding need to shut
      off the destination QEMU. In the new split, socket setup is done
      after the 'prepare' step. This is not a serious problem, since
      the control flow already requires calling 'finish' to tear down
      the destination QEMU upon several errors.
      
      * src/qemu/qemu_migration.c:
      13cb49f8
    • D
      Wire up SPICE client relocation with QEMU migration · cc53b4c4
      Daniel P. Berrange 提交于
      Use the graphics information from the QEMU migration cookie to
      issue a 'client_migrate_info' monitor command to QEMU. This causes
      the SPICE client to automatically reconnect to the target host
      when migration completes
      
      * src/qemu/qemu_migration.c: Set data for SPICE client relocation
        before starting migration on src
      * src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
        src/qemu/qemu_monitor_json.c, src/qemu/qemu_monitor_json.h,
        src/qemu/qemu_monitor_text.c, src/qemu/qemu_monitor_text.h: Add
        new qemuMonitorGraphicsRelocate() command
      cc53b4c4
    • D
      Pass graphics setup from dst back to src via migration cookies · 72de0d28
      Daniel P. Berrange 提交于
      Extend the QEMU migration cookie structure to allow information
      about the destination host graphics setup to be passed by to
      the source host. This will enable seamless migration of any
      connected graphics clients
      
      * src/qemu/qemu_migration.c: Add graphics info to migration
        cookies
      * daemon/libvirtd.c: Always initialize gnutls to enable
        x509 cert parsing in QEMU
      72de0d28
    • D
      Introduce migration cookies to QEMU driver · 8654175c
      Daniel P. Berrange 提交于
      The migration protocol has support for a 'cookie' parameter which
      is an opaque array of bytes as far as libvirt is concerned. Drivers
      may use this for passing around arbitrary extra data they might
      need during migration. The QEMU driver needs to do a few things:
      
       - Pass hostname/uuid to allow strict protection against localhost
         migration attempts
       - Pass SPICE/VNC server port from the target back to the source to
         allow seamless relocation of client sessions
       - Pass lock driver state from source to destination
      
      This patch introduces the basic glue for handling cookies
      but only includes the host/guest UUID & name.
      
      * src/libvirt_private.syms: Export virXMLParseStrHelper
      * src/qemu/qemu_migration.c, src/qemu/qemu_migration.h: Parsing
        and formatting of migration cookies
      * src/qemu/qemu_driver.c: Pass in cookie parameters where possible
      * src/remote/remote_protocol.h, src/remote/remote_protocol.x: Change
        cookie max length to 16384 bytes
      8654175c
    • D
      Fix locking with qemuMigrationPrepareTunnel method · 9ab24558
      Daniel P. Berrange 提交于
      The qemuMigrationPrepareTunnel method should not unlock the
      qemu driver, since that is the caller's job.
      
      * src/qemu/qemu_migration.c: Fix qemuMigrationPrepareTunnel
        unlocking of QEMU driver
      9ab24558
    • J
      Implement domain state reason · b046c55d
      Jiri Denemark 提交于
      Only in drivers which use virDomainObj, drivers that query hypervisor
      for domain status need to be updated separately in case their hypervisor
      supports this functionality.
      
      The reason is also saved into domain state XML so if a domain is not
      running (i.e., no state XML exists) the reason will be lost by libvirtd
      restart. I think this is an acceptable limitation.
      b046c55d
  14. 12 5月, 2011 1 次提交
    • L
      libvirt,logging: cleanup VIR_XXX0() · b65f37a4
      Lai Jiangshan 提交于
      These VIR_XXXX0 APIs make us confused, use the non-0-suffix APIs instead.
      
      How do these coversions works? The magic is using the gcc extension of ##.
      When __VA_ARGS__ is empty, "##" will swallow the "," in "fmt," to
      avoid compile error.
      
      example: origin				after CPP
      	high_level_api("%d", a_int)	low_level_api("%d", a_int)
      	high_level_api("a  string")	low_level_api("a  string")
      
      About 400 conversions.
      
      8 special conversions:
      VIR_XXXX0("") -> VIR_XXXX("msg") (avoid empty format) 2 conversions
      VIR_XXXX0(string_literal_with_%) -> VIR_XXXX(%->%%) 0 conversions
      VIR_XXXX0(non_string_literal) -> VIR_XXXX("%s", non_string_literal)
        (for security) 6 conversions
      Signed-off-by: NLai Jiangshan <laijs@cn.fujitsu.com>
      b65f37a4
  15. 05 5月, 2011 1 次提交