1. 28 4月, 2012 7 次提交
    • M
      qemu_agent: Report error class at least · 37803108
      Michal Privoznik 提交于
      Currently, qemu GA is not providing 'desc' field for errors like
      we are used to from qemu monitor. Therefore, we fall back to this
      general 'unknown error' string. However, GA is reporting 'class' which
      is not perfect, but much more helpful than generic error string.
      Thus we should fall back to class firstly and if even no class
      is presented, then we can fall back to that generic string.
      
      Before this patch:
      virsh # dompmsuspend --target mem f16
      error: Domain f16 could not be suspended
      error: internal error unable to execute QEMU command
      'guest-suspend-ram': unknown QEMU command error
      
      After this patch:
      virsh # dompmsuspend --target mem f16
      error: Domain f16 could not be suspended
      error: internal error unable to execute QEMU command
      'guest-suspend-ram': The command has not been found
      37803108
    • S
      More coverity findings addressed · 59b935f5
      Stefan Berger 提交于
      More bug extermination in the category of:
      
      Error: CHECKED_RETURN:
      
      /libvirt/src/conf/network_conf.c:595:
      check_return: Calling function "virAsprintf" without checking return value (as is done elsewhere 515 out of 543 times).
      
      /libvirt/src/qemu/qemu_process.c:2780:
      unchecked_value: No check of the return value of "virAsprintf(&msg, "was paused (%s)", virDomainPausedReasonTypeToString(reason))".
      
      /libvirt/tests/commandtest.c:809:
      check_return: Calling function "setsid" without checking return value (as is done elsewhere 4 out of 5 times).
      
      /libvirt/tests/commandtest.c:830:
      unchecked_value: No check of the return value of "virTestGetDebug()".
      
      /libvirt/tests/commandtest.c:831:
      check_return: Calling function "virTestGetVerbose" without checking return value (as is done elsewhere 41 out of 42 times).
      
      /libvirt/tests/commandtest.c:833:
      check_return: Calling function "virInitialize" without checking return value (as is done elsewhere 18 out of 21 times).
      
      
      One note about the error in commandtest line 809: setsid() seems to fail when running the test -- could be removed ?
      59b935f5
    • E
      blockjob: fix block-stream bandwidth race · 2eabac00
      Eric Blake 提交于
      With RHEL 6.2, virDomainBlockPull(dom, dev, bandwidth, 0) has a race
      with non-zero bandwidth: there is a window between the block_stream
      and block_job_set_speed monitor commands where an unlimited amount
      of data was let through, defeating the point of a throttle.
      
      This race was first identified in commit a9d3495e, and libvirt was
      able to reduce the size of the window for that race.  In the meantime,
      the qemu developers decided to fix things properly; per this message:
      https://lists.gnu.org/archive/html/qemu-devel/2012-04/msg03793.html
      the fix will be in qemu 1.1, and changes block-job-set-speed to use
      a different parameter name, as well as adding a new optional parameter
      to block-stream, which eliminates the race altogether.
      
      Since our documentation already mentioned that we can refuse a non-zero
      bandwidth for some hypervisors, I think the best solution is to do
      just that for RHEL 6.2 qemu, so that the race is obvious to the user
      (anyone using stock RHEL 6.2 binaries won't have this patch, and anyone
      building their own libvirt with this patch for RHEL can also rebuild
      qemu to get the modern semantics, so it is no real loss in behavior).
      
      Meanwhile the code must be fixed to honor actual qemu 1.1 naming.
      Rename the parameter to 'modern', since the naming difference now
      covers more than just 'async' block-job-cancel.  And while at it,
      fix an unchecked integer overflow.
      
      * src/qemu/qemu_monitor.h (enum BLOCK_JOB_CMD): Drop unused value,
      rename enum to match conventions.
      * src/qemu/qemu_monitor.c (qemuMonitorBlockJob): Reflect enum rename.
      * src/qemu_qemu_monitor_json.h (qemuMonitorJSONBlockJob): Likewise.
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockJob): Likewise,
      and support difference between RHEL 6.2 and qemu 1.1 block pull.
      * src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Reject
      bandwidth during pull with too-old qemu.
      * src/libvirt.c (virDomainBlockPull, virDomainBlockRebase):
      Document this.
      2eabac00
    • S
      lxc: Fix coverity findings · f74471de
      Stefan Berger 提交于
      Error: UNINIT:
      /libvirt/src/lxc/lxc_driver.c:1412:
      var_decl: Declaring variable "fd" without initializer.
      /libvirt/src/lxc/lxc_driver.c:1460:
      uninit_use_in_call: Using uninitialized value "fd" when calling "virFileClose".
      /libvirt/src/util/virfile.c:50:
      read_parm: Reading a parameter value.
      
      Error: DEADCODE:
      /libvirt/src/lxc/lxc_controller.c:960:
      dead_error_condition: On this path, the condition "ret == 4" cannot be true.
      /libvirt/src/lxc/lxc_controller.c:959:
      at_most: After this line, the value of "ret" is at most -1.
      /libvirt/src/lxc/lxc_controller.c:959:
      new_values: Noticing condition "ret < 0".
      /libvirt/src/lxc/lxc_controller.c:961:
      dead_error_line: Execution cannot reach this statement "continue;".
      
      Error: UNINIT:
      /libvirt/src/lxc/lxc_controller.c:1104:
      var_decl: Declaring variable "consoles" without initializer.
      /libvirt/src/lxc/lxc_controller.c:1237:
      uninit_use: Using uninitialized value "consoles".
      f74471de
    • C
      python: Fix doc directory name for stable releases · 002b18b3
      Cole Robinson 提交于
      We were using the libvirt release version (like 0.9.11) and not
      the configure version (which for stable releases is 0.9.11.X)
      
      Most other places got this right so hopefully that's all the fallout
      from the version format change :)
      Signed-off-by: NCole Robinson <crobinso@redhat.com>
      002b18b3
    • C
      docs: Serialize running apibuild.py · c964b6aa
      Cole Robinson 提交于
      Use a witness file approach like we do for python/generator.py,
      as suggested by Eric. Fixes the build issue reported here:
      
      https://www.redhat.com/archives/libvir-list/2012-April/msg01435.htmlSigned-off-by: NCole Robinson <crobinso@redhat.com>
      c964b6aa
    • C
      configure: Use ustar format for dist tarball · ddd6bef4
      Cole Robinson 提交于
      Since for stable releases, some test files were over the 99 char
      limit for traditional tar filenames.
      
      Suggested by Osier here:
      https://www.redhat.com/archives/libvir-list/2012-April/msg01435.htmlSigned-off-by: NCole Robinson <crobinso@redhat.com>
      ddd6bef4
  2. 27 4月, 2012 6 次提交
    • J
      qemu: Use common helper when probing qemu capabilities · 2d76fea1
      Jiri Denemark 提交于
      QEMU binary is called several times when we probe different kinds of
      capabilities the binary supports. This patch introduces new common
      helper so that all probes use a consistent way of invoking qemu.
      2d76fea1
    • E
      qemu: improve errors related to offline domains · 8e532d34
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=816662 pointed out
      that attempting 'virsh blockpull' on an offline domain gave a
      misleading error message about qemu lacking support for the
      operation, even when qemu was specifically updated to support it.
      The real problem is that we have several capabilities that are
      only determined when starting a domain, and therefore are still
      clear when first working with an inactive domain (namely, any
      capability set by qemuMonitorJSONCheckCommands).
      
      While this patch was able to hoist an existing check in one of the
      three culprits, it had to add redundant checks in the other two
      places (because you always have to check for an active domain after
      obtaining a VM job lock, but the capability bits were being checked
      prior to obtaining the job lock).
      
      Someday it would be nice to patch libvirt to cache the set of
      capabilities per qemu binary (as determined by inode and timestamp),
      rather than re-probing the binary every time a domain is started,
      and to teach the cache how to query the monitor during the one
      time the probe is made rather than having to wait until a guest
      is started; then, a capability probe would succeed even for offline
      guests because it just refers to the cache, and the single check for
      an active domain after grabbing the job lock would be sufficient.
      But since that will involve a lot more coding, I'm happy to go
      with this simpler solution for an immediate solution.
      
      * src/qemu/qemu_driver.c (qemuDomainPMSuspendForDuration)
      (qemuDomainSnapshotCreateXML, qemuDomainBlockJobImpl): Check for
      offline state before checking an online-only cap.
      8e532d34
    • S
      macvtap: fix a typo · 4bf9061e
      Stefan Berger 提交于
      Below patch fixes the following coverity findings
      
      Error: OVERRUN_STATIC:
      /libvirt/src/qemu/qemu_command.c:152:
      overrun-buffer-val: Overrunning static array "net->mac" of size 6 bytes by passing it as an argument to a function which indexes it at byte position 15.
      /libvirt/src/util/virnetdevmacvlan.c:948:
      access_dbuff_const: Calling "virNetDevMacVLanVPortProfileRegisterCallback" indexes array "macaddress" at byte position 15.
      /libvirt/src/util/virnetdevmacvlan.c:773:
      access_dbuff_const: Calling "memcpy" indexes array "macaddress" with index "16UL" at byte position 15.
      
      Error: OVERRUN_STATIC:
      /libvirt/src/qemu/qemu_migration.c:2744:
      overrun-buffer-val: Overrunning static array "net->mac" of size 6 bytes by passing it as an argument to a function which indexes it at byte position 15.
      /libvirt/src/util/virnetdevmacvlan.c:773:
      access_dbuff_const: Calling "memcpy" indexes array "macaddress" with index "16UL" at byte position 15.
      
      Error: OVERRUN_STATIC:
      /libvirt/src/qemu/qemu_driver.c:435:
      overrun-buffer-val: Overrunning static array "net->mac" of size 6 bytes by passing it as an argument to a function which indexes it at byte position 15.
      /libvirt/src/util/virnetdevmacvlan.c:1036:
      access_dbuff_const: Calling "virNetDevMacVLanVPortProfileRegisterCallback" indexes array "macaddress" at byte position 15.
      /libvirt/src/util/virnetdevmacvlan.c:773:
      access_dbuff_const: Calling "memcpy" indexes array "macaddress" with index "16UL" at byte position 15.
      
      4bf9061e
    • S
      nwfilter: address more coverity findings · 42548fbf
      Stefan Berger 提交于
      This patch addresses the following coverity findings:
      
      /libvirt/src/conf/nwfilter_params.c:390:
      var_assigned: Assigning: "varValue" = null return value from "virHashLookup".
      
      /libvirt/src/conf/nwfilter_params.c:392:
      dereference: Dereferencing a pointer that might be null "varValue" when calling "virNWFilterVarValueGetNthValue".
      
      /libvirt/src/conf/nwfilter_params.c:399:
      dereference: Dereferencing a pointer that might be null "tmp" when calling "virNWFilterVarValueGetNthValue".
      42548fbf
    • S
      nwfilter: address coverity findings · 9c1ce3dc
      Stefan Berger 提交于
      This patch addresses the following coverity findings:
      
      /libvirt/src/conf/nwfilter_params.c:157:
      deref_parm: Directly dereferencing parameter "val".
      
      /libvirt/src/conf/nwfilter_params.c:473:
      negative_returns: Using variable "iterIndex" as an index to array "res->iter".
      
      /libvirt/src/nwfilter/nwfilter_ebiptables_driver.c:2891:
      unchecked_value: No check of the return value of "virAsprintf(&protostr, "-d 01:80:c2:00:00:00 ")".
      
      /libvirt/src/nwfilter/nwfilter_ebiptables_driver.c:2894:
      unchecked_value: No check of the return value of "virAsprintf(&protostr, "-p 0x%04x ", l3_protocols[protoidx].attr)".
      
      /libvirt/src/nwfilter/nwfilter_ebiptables_driver.c:3590:
      var_deref_op: Dereferencing null variable "inst".
      9c1ce3dc
    • L
      util: fix error messages in virNetlinkEventServiceStart · 9586925b
      Laine Stump 提交于
      Some of the error messages in this function should have been
      virReportSystemError (since they have an errno they want to log), but
      were mistakenly written as netlinkError, which expects a libvirt error
      code instead. The result was that when one of the errors was
      encountered, "No error message provided" would be printed instead of
      something meaningful (see
      https://bugzilla.redhat.com/show_bug.cgi?id=816465 for an example).
      9586925b
  3. 26 4月, 2012 7 次提交
    • J
      qemu: Avoid bogus error at the end of tunnelled migration · 8ef5f263
      Jiri Denemark 提交于
      Once qemu monitor reports migration has completed, we just closed our
      end of the pipe and let migration tunnel die. This generated bogus error
      in case we did so before the thread saw EOF on the pipe and migration
      was aborted even though it was in fact successful.
      
      With this patch we first wake up the tunnel thread and once it has read
      all data from the pipe and finished the stream we close the
      filedescriptor.
      
      A small additional bonus of this patch is that real errors reported
      inside qemuMigrationIOFunc are not overwritten by virStreamAbort any
      more.
      8ef5f263
    • J
      qemu: Fix detection of failed migration · 25a63451
      Jiri Denemark 提交于
      When QEMU reported failed or canceled migration, we correctly detected
      it but didn't really consider it as an error condition and migration
      protocol just went on. Luckily, some of the subsequent steps eventually
      failed end we reported an (unrelated and mostly random) error back to
      the caller.
      25a63451
    • J
      rpc: Discard non-blocking calls only when necessary · b1e374a7
      Jiri Denemark 提交于
      Currently, non-blocking calls are either sent immediately or discarded
      in case sending would block. This was implemented based on the
      assumption that the non-blocking keepalive call is not needed as there
      are other calls in the queue which would keep the connection alive.
      However, if those calls are no-reply calls (such as those carrying
      stream data), the remote party knows the connection is alive but since
      we don't get any reply from it, we think the connection is dead.
      
      This is most visible in tunnelled migration. If it happens to be longer
      than keepalive timeout (30s by default), it may be unexpectedly aborted
      because the connection is considered to be dead.
      
      With this patch, we only discard non-blocking calls when the last call
      with a thread is completed and thus there is no thread left to keep
      sending the remaining non-blocking calls.
      b1e374a7
    • J
      qemu: Preserve original error during migration · 6d646947
      Jiri Denemark 提交于
      In some cases (spotted with broken connection during tunneled migration)
      we were overwriting the original error with worse or even misleading
      errors generated when we were cleaning up after failed migration.
      6d646947
    • P
      keepalive: Add ability to disable keepalive messages · 6446a9e2
      Peter Krempa 提交于
      The docs for virConnectSetKeepAlive() advertise that this function
      should be able to disable keepalives on negative or zero interval time.
      
      This patch removes the check that prohibited this and adds code to
      disable keepalives on negative/zero interval.
      
      * src/libvirt.c: virConnectSetKeepAlive(): - remove check for negative
                                                   values
      * src/rpc/virnetclient.c
      * src/rpc/virnetclient.h: - add virNetClientKeepAliveStop() to disable
                                  keepalive messages
      * src/remote/remote_driver.c: remoteSetKeepAlive(): -add ability to
                                                           disable keepalives
      6446a9e2
    • L
      util: fix crash when starting macvtap interfaces · f78024b9
      Laine Stump 提交于
      This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270
      
      The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
      arg "virtPortProfile", and was checking it for non-NULL before using
      it. However, the prototype for
      virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
      ATTRIBUTE_NONNULL(). Contrary to what one may think,
      ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
      as such really is always non-null; the only effect to the code
      generated by gcc, is that gcc *assumes* it is non-NULL; this results
      in, for example, the check for a non-NULL value being optimized out.
      
      (Unfortunately, this code removal only occurs when optimization is
      enabled, and I am in the habit of doing local builds with optimization
      off to ease debugging, so the bug didn't show up in my earlier local
      testing).
      
      In general, virPortProfile might always be NULL, so it shouldn't be
      marked as ATTRIBUTE_NONNULL. One other function prototype made this
      same error, so this patch fixes it as well.
      f78024b9
    • E
      build: fix bootstrap on RHEL · bae13129
      Eric Blake 提交于
      Commit 8fe455fd tried to work around
      a regression introduced in upstream gnulib that requires gettext 0.18
      or newer on all projects using bootstrap, by making libvirt require
      gettext 0.18.  But this fails on RHEL 6.2, which still ships gettext
      0.17.  Revert that change, and instead, import the latest round of
      gnulib updates that fix that problem properly.
      
      If you have already built in the window where libvirt required 0.18,
      be aware that incremental updates may run into problems: this is
      because 'autopoint --force' will not downgrade m4/po.m4 back to an
      older version, but it must be downgraded back to 0.17 levels to work
      with this patch.  You may either manually remove that file then rerun
      bootstrap, or it may prove easier to just clean up all non-git files
      to start from a clean slate.
      
      * bootstrap.conf: Revert minimum gettext back to 0.17.
      * configure.ac: Likewise.
      * .gnulib: Update to latest, for bootstrap fixes.
      * bootstrap: Resync from gnulib.
      bae13129
  4. 25 4月, 2012 2 次提交
  5. 24 4月, 2012 5 次提交
    • S
      Improve on virAtomic implementation · a4a5c00b
      Stefan Berger 提交于
      This patch improves the previously added virAtomicInt implementation
      by using gcc-builtins if possible. The needed builtins are available
      since GCC >= 4.1. At least the 4.0 docs don't mention them.
      a4a5c00b
    • H
      fix memleak in linuxParseCPUmap · 3ac30361
      Hu Tao 提交于
      3ac30361
    • P
      build: Fix version of gettext macros · 8fe455fd
      Peter Krempa 提交于
      Commit c9cd419c added copying of the
      makefile for translation files from gnulib. The makefile from gnulib is
      of version 0.18 but the build configuration cretes macros from version
      0.17 which breaks the build with message:
      
      *** error: gettext infrastructure mismatch: using a Makefile.in.in from
      gettext version 0.18 but the autoconf macros are from gettext version
      0.17
      8fe455fd
    • M
      vbox: Fix passing an empty IMedium* array to IMachine::Delete · a9bc123e
      Matthias Bolte 提交于
      vboxArray is not castable to a COM item type. vboxArray is a
      wrapper around the XPCOM and MSCOM specific array handling.
      
      In this case we can avoid passing NULL as an empty array to
      IMachine::Delete by passing a dummy IMedium* array with a single
      NULL item.
      a9bc123e
    • G
      openvz: add network interface stats · 52ee7c2b
      Guido Günther 提交于
      This will only work for veth devices since venet devices don't have
      a target element.
      52ee7c2b
  6. 23 4月, 2012 4 次提交
    • E
      blockjob: enhance xml to track mirrors across libvirtd restart · ae6aa8c3
      Eric Blake 提交于
      In order to track a block copy job across libvirtd restarts, we
      need to save internal XML that tracks the name of the file
      holding the mirror.  Displaying this name in dumpxml might also
      be useful to the user, even if we don't yet have a way to (re-)
      start a domain with mirroring enabled up front.  This is done
      with a new <mirror> sub-element to <disk>, as in:
      
          <disk type='file' device='disk'>
            <driver name='qemu' type='raw'/>
            <source file='/var/lib/libvirt/images/original.img'/>
            <mirror file='/var/lib/libvirt/images/copy.img' format='qcow2' ready='yes'/>
            ...
          </disk>
      
      For now, the element is output-only, in live domains; it is ignored
      when defining a domain or hot-plugging a disk (since those contexts
      use VIR_DOMAIN_XML_INACTIVE in parsing).  The 'ready' attribute appears
      when libvirt knows that the job has changed from the initial pulling
      phase over to the mirroring phase, although absence of the attribute
      is not a sure indicator of the current phase.  If we come up with a way
      to make qemu start with mirroring enabled, we can relax the xml
      restriction, and allow <mirror> (but not attribute 'ready') on input.
      Testing active-only XML meant tweaking the testsuite slightly, but it
      was worth it.
      
      * docs/schemas/domaincommon.rng (diskspec): Add diskMirror.
      * docs/formatdomain.html.in (elementsDisks): Document it.
      * src/conf/domain_conf.h (_virDomainDiskDef): New members.
      * src/conf/domain_conf.c (virDomainDiskDefFree): Clean them.
      (virDomainDiskDefParseXML): Parse them, but only internally.
      (virDomainDiskDefFormat): Output them.
      * tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: New test file.
      * tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror.xml: Likewise.
      * tests/qemuxml2xmltest.c (testInfo): Alter members.
      (testCompareXMLToXMLHelper): Allow more test control.
      (mymain): Run new test.
      ae6aa8c3
    • E
      blockjob: add 'blockcopy' to virsh · 1f06c007
      Eric Blake 提交于
      Rather than further overloading 'blockpull', I decided to create a
      new virsh command to expose the new flags of virDomainBlockRebase.
      
      Blocking until the command completes naturally is pointless, since
      the block copy job is intended to run indefinitely.  Instead, I
      made the command support three --wait modes: by default, it runs until
      mirroring is started; with --pivot, it pivots as soon as mirroring
      is started; and with --finish, it aborts (for a clean copy) as
      soon as mirroring is started.
      
      * tools/virsh.c (VSH_CMD_BLOCK_JOB_COPY): New mode.
      (blockJobImpl): Support new flags.
      (cmdBlockCopy): New command.
      (cmdBlockJob): Support new job info, new abort flag.
      * tools/virsh.pod (blockcopy, blockjob): Document the new command
      and flags.
      1f06c007
    • E
      blockjob: add new API flags · 36484692
      Eric Blake 提交于
      This patch introduces a new block job, useful for live storage
      migration using pre-copy streaming.  Justification for including
      this under virDomainBlockRebase rather than adding a new command
      includes: 1) there are now two possible block jobs in qemu, with
      virDomainBlockRebase starting either type of command, and
      virDomainBlockJobInfo and virDomainBlockJobAbort working to end
      either type; 2) reusing this command allows distros to backport
      this feature to the libvirt 0.9.10 API without a .so bump.
      
      Note that a future patch may add a more powerful interface named
      virDomainBlockJobCopy, dedicated to just the block copy job, in
      order to expose even more options (such as setting an arbitrary
      format type for the destination without having to probe it from a
      pre-existing destination file); adding a new command for targetting
      just block copy would be similar to how we already have
      virDomainBlockPull for targetting just the block pull job.
      
      Using a live VM with the backing chain:
        base <- snap1 <- snap2
      as the starting point, we have:
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY)
      creates /path/to/copy with the same format as snap2, with no backing
      file, so entire chain is copied and flattened
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      creates /path/to/copy as a raw file, so entire chain is copied and
      flattened
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
      creates /path/to/copy with the same format as snap2, but with snap1 as
      a backing file, so only snap2 is copied.
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT)
      reuse existing /path/to/copy (must have empty contents, and format is
      probed[*] from the metadata), and copy the full chain
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
          VIR_DOMAIN_BLOCK_REBASE_SHALLOW)
      reuse existing /path/to/copy (contents must be identical to snap1,
      and format is probed[*] from the metadata), and copy only the contents
      of snap2
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
          VIR_DOMAIN_BLOCK_REBASE_SHALLOW|VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      reuse existing /path/to/copy (must be raw volume with contents
      identical to snap1), and copy only the contents of snap2
      
      Less useful combinations:
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_SHALLOW|
          VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      fail if source is not raw, otherwise create /path/to/copy as raw and
      the single file is copied (no chain involved)
      
      - virDomainBlockRebase(dom, disk, "/path/to/copy", 0,
          VIR_DOMAIN_BLOCK_REBASE_COPY|VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT|
          VIR_DOMAIN_BLOCK_REBASE_COPY_RAW)
      makes little sense: the destination must be raw but have no contents,
      meaning that it is an empty file, so there is nothing to reuse
      
      The other three flags are rejected without VIR_DOMAIN_BLOCK_COPY.
      
      [*] Note that probing an existing file for its format can be a security
      risk _if_ there is a possibility that the existing file is 'raw', in
      which case the guest can manipulate the file to appear like some other
      format.  But, by virtue of the VIR_DOMAIN_BLOCK_REBASE_COPY_RAW flag,
      it is possible to avoid probing of raw files, at which point, probing
      of any remaining file type is no longer a security risk.
      
      It would be nice if we could issue an event when pivoting from phase 1
      to phase 2, but qemu hasn't implemented that, and we would have to poll
      in order to synthesize it ourselves.  Meanwhile, qemu will give us a
      distinct job info and completion event when we either cancel or pivot
      to end the job.  Pivoting is accomplished via the new:
      
      virDomainBlockJobAbort(dom, disk, VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT)
      
      Management applications can pre-create the copy with a relative
      backing file name, and use the VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT
      flag to have qemu reuse the metadata; if the management application
      also copies the backing files to a new location, this can be used
      to perform live storage migration of an entire backing chain.
      
      * include/libvirt/libvirt.h.in (VIR_DOMAIN_BLOCK_JOB_TYPE_COPY):
      New block job type.
      (virDomainBlockJobAbortFlags, virDomainBlockRebaseFlags): New enums.
      * src/libvirt.c (virDomainBlockRebase): Document the new flags,
      and implement general restrictions on flag combinations.
      (virDomainBlockJobAbort): Document the new flag.
      (virDomainSaveFlags, virDomainSnapshotCreateXML)
      (virDomainRevertToSnapshot, virDomainDetachDeviceFlags): Document
      restrictions.
      * include/libvirt/virterror.h (VIR_ERR_BLOCK_COPY_ACTIVE): New
      error.
      * src/util/virterror.c (virErrorMsg): Define it.
      36484692
    • P
      cpu: Improve error reporting on incompatible CPUs · a2ba53cf
      Peter Krempa 提交于
      This patch modifies the CPU comparrison function to report the
      incompatibilities in more detail to ease identification of problems.
      
      * src/cpu/cpu.h:
          cpuGuestData(): Add argument to return detailed error message.
      * src/cpu/cpu.c:
          cpuGuestData(): Add passthrough for error argument.
      * src/cpu/cpu_x86.c
          x86FeatureNames(): Add function to convert a CPU definition to flag
                             names.
          x86Compute(): - Add error message parameter
                        - Add macro for reporting detailed error messages.
                        - Improve error reporting.
                        - Simplify calculation of forbidden flags.
          x86DataIteratorInit():
          x86cpuidMatchAny(): Remove functions that are no longer needed.
      * src/qemu/qemu_command.c:
          qemuBuildCpuArgStr(): - Modify for new function prototype
                                - Add detailed error reports
                                - Change error code on incompatible processors
                                  to VIR_ERR_CONFIG_UNSUPPORTED instead of
                                  internal error
      * tests/cputest.c:
          cpuTestGuestData(): Modify for new function prototype
      a2ba53cf
  7. 22 4月, 2012 2 次提交
    • W
      building: remove libvirt_dbus.syms from EXTRA_DIST · 28ae4f0c
      Wen Congyang 提交于
      commit 2223ea98 removes src/libvirt_dbus.syms, but it forgets
      to remove it from EXTRA_DIST. It will cause 'make dist' failed.
      28ae4f0c
    • M
      win32: Properly handle TlsGetValue returning NULL · e0aba54b
      Matthias Bolte 提交于
      virThreadSelf tries to access the virThreadPtr stored in TLS for the
      current thread via TlsGetValue. When virThreadSelf is called on a thread
      that was not created via virThreadCreate (e.g. the main thread) then
      TlsGetValue returns NULL as TlsAlloc initializes TLS slots to NULL.
      
      virThreadSelf can be called on the main thread via this call chain from
      virsh
      
      vshDeinit
      virEventAddTimeout
      virEventPollAddTimeout
      virEventPollInterruptLocked
      virThreadIsSelf
      
      triggering a segfault as virThreadSelf unconditionally dereferences the
      return value of TlsGetValue.
      
      Fix this by making virThreadSelf check the TLS slot value for NULL and
      setting the given virThreadPtr accordingly.
      
      Reported by Marcel Müller.
      e0aba54b
  8. 21 4月, 2012 1 次提交
  9. 20 4月, 2012 6 次提交
    • G
      openvz: wire up getHostname · 995b5b3d
      Guido Günther 提交于
      995b5b3d
    • E
      virnetserver: handle sigaction correctly · f4346173
      Eric Blake 提交于
      POSIX says that sa_sigaction is only safe to use if sa_flags
      includes SA_SIGINFO; conversely, sa_handler is only safe to
      use when flags excludes that bit.  Gnulib doesn't guarantee
      an implementation of SA_SIGINFO, but does guarantee that
      if SA_SIGINFO is undefined, we can safely define it to 0 as
      long as we don't dereference the 2nd or 3rd argument of
      any handler otherwise registered via sa_sigaction.
      
      Based on a report by Wen Congyang.
      
      * src/rpc/virnetserver.c (SA_SIGINFO): Stub for mingw.
      (virNetServerSignalHandler): Avoid bogus dereference.
      (virNetServerFatalSignal, virNetServerNew): Set flags properly.
      (virNetServerAddSignalHandler): Drop unneeded #ifdef.
      f4346173
    • E
      conf: remove redundant () · 6877a34d
      Eric Blake 提交于
      I almost copied-and-pasted some redundant () into my new code,
      and figured a general cleanup prereq patch would be better instead.
      
      No semantic change.
      
      * src/conf/domain_conf.c (virDomainLeaseDefParseXML)
      (virDomainDiskDefParseXML, virDomainFSDefParseXML)
      (virDomainActualNetDefParseXML, virDomainNetDefParseXML)
      (virDomainGraphicsDefParseXML, virDomainVideoAccelDefParseXML)
      (virDomainVideoDefParseXML, virDomainHostdevFind)
      (virDomainControllerInsertPreAlloced, virDomainDefParseXML)
      (virDomainObjParseXML, virDomainCpuSetFormat)
      (virDomainCpuSetParse, virDomainDiskDefFormat)
      (virDomainActualNetDefFormat, virDomainNetDefFormat)
      (virDomainTimerDefFormat, virDomainGraphicsListenDefFormat)
      (virDomainDefFormatInternal, virDomainNetGetActualHostdev)
      (virDomainNetGetActualBandwidth, virDomainGraphicsGetListen):
      Reduce extra ().
      6877a34d
    • E
      build: avoid strtol and strtod · ae27f341
      Eric Blake 提交于
      Ensure we don't introduce any more lousy integer parsing in new
      code, while avoiding a scrub-down of existing legacy code.
      
      Note that we also need to enable sc_prohibit_atoi_atof (see cfg.mk
      local-checks-to-skip) before we are bulletproof, but that also
      entails scrubbing I'm not ready to do at the moment.
      
      * src/util/util.c (virStrToLong_i, virStrToLong_ui)
      (virStrToLong_l, virStrToLong_ul, virStrToLong_ll)
      (virStrToLong_ull, virStrToDouble): Mark exemptions.
      * src/util/virmacaddr.c (virMacAddrParse): Likewise.
      * cfg.mk (sc_prohibit_strtol): New syntax check.
      (exclude_file_name_regexp--sc_prohibit_strtol): Ignore files that
      I'm not willing to fix yet.
      (local-checks-to-skip): Re-enable sc_prohibit_atoi_atof.
      ae27f341
    • E
      conf: tighten up XML integer parsing · c09acad3
      Eric Blake 提交于
      https://bugzilla.redhat.com/show_bug.cgi?id=617711 reported that
      even with my recent patched to allow <memory unit='G'>1</memory>,
      people can still get away with trying <memory>1G</memory> and
      silently get <memory unit='KiB'>1</memory> instead.  While
      virt-xml-validate catches the error, our C parser did not.
      
      Not to mention that it's always fun to fix bugs while reducing
      lines of code.  :)
      
      * src/conf/domain_conf.c (virDomainParseMemory): Check for parse error.
      (virDomainDefParseXML): Avoid strtoll.
      * src/conf/storage_conf.c (virStorageDefParsePerms): Likewise.
      * src/util/xml.c (virXPathLongBase, virXPathULongBase)
      (virXPathULongLong, virXPathLongLong): Likewise.
      c09acad3
    • E
      virsh: avoid strtol · bb65c8af
      Eric Blake 提交于
      We were forgetting to check errno for overflow.
      
      * tools/virsh.c (get_integer_keycode, vshCommandOptInt)
      (vshCommandOptUInt, vshCommandOptUL, vshCommandOptLongLong)
      (vshCommandOptULongLong): Rewrite to be safer.
      bb65c8af