1. 01 8月, 2011 6 次提交
    • A
      qemu: fix return value issue · c03f7f13
      Alex Jia 提交于
      whether or not previous return value is -1, the following codes will be
      executed for a inactive guest in src/qemu/qemu_driver.c:
      ret = virDomainSaveConfig(driver->configDir, persistentDef);
      and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
      will be overwritten, this patch will fix this issue.
      
      * src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
        in out of blkio weight range for a inactive guest.
      
      * how to reproduce?
        % virsh blkiotune ${guestname} --weight 10
        % echo $?
      
        Note: guest must be inactive, argument 10 in out of blkio weight range,
        and can get a error information by checking libvirtd.log, however,
        virsh hasn't raised any error information, and return value is 0.
      
        https://bugzilla.redhat.com/show_bug.cgi?id=726304Signed-off-by: NAlex Jia <ajia@redhat.com>
      c03f7f13
    • A
      qemu: fix return value issue in qemuDomainSetMemoryParameters · 868453db
      Alex Jia 提交于
      whether or not previous return value is -1, the following codes will be
      executed for a inactive guest in qemuDomainSetMemoryParameters:
      ret = virDomainSaveConfig(driver->configDir, persistentDef);
      and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
      will be overwritten, this patch will fix this issue.
      
      * src/qemu/qemu_driver.c: avoid return value is overwritten when set
        min_guarante value to a inactive guest.
      
      * how to reproduce?
        % virsh memtune ${guestname} --min_guarante 1024
        % echo $?
      
        Note: guest must be inactive, in fact, 'min_guarante' hasn't been implemented
        in memory tunable, and I can get the error when check actual libvirtd.log,
        however, virsh hasn't raised any error information, and return value is 0.
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      868453db
    • M
      virsh: Fix vol-name and vol-pool commands · c9ee3d26
      Matthias Bolte 提交于
      This commands don't have a --pool option, so don't tell
      vshCommandOptVolBy that there could be one. This made
      vshCommandOptString for pooloptname fail and an "missing option"
      error was reported.
      
      Make pooloptname optional for vshCommandOptVolBy.
      c9ee3d26
    • G
      Correct the default value of lock_manager in qemu.conf · 2f6239d0
      Guannan Ren 提交于
      * src/qemu/qemu.conf: switch back the comment for the default lock
        manager to sanlock
      2f6239d0
    • O
      qemu: Fix a regression of domjobabort · f362a99a
      Osier Yang 提交于
      Introduced by f9a837da, the condition is not changed after
      the else clause is removed. So now it quit with "domain is not
      running" when the domain is running. However, when the domain is
      not running, it reports "no job is active".
      
      How to reproduce:
      
      1)
      % virsh start $domain
      % virsh domjobabort $domain
      error: Requested operation is not valid: domain is not running
      
      2)
      % virsh destroy $domain
      % virsh domjobabort $domain
      error: Requested operation is not valid: no job is active on the domain
      
      3)
      % virsh save $domain /tmp/$domain.save
      
      Before above commands finished, try to abort job in another terminal
      
      % virsh domabortjob $domain
      error: Requested operation is not valid: domain is not running
      f362a99a
    • M
      conf: Don't leak the virtual port profile in virNetworkDefFree · 49b8d51e
      Matthias Bolte 提交于
      Reported by Alex Jia.
      49b8d51e
  2. 30 7月, 2011 5 次提交
    • E
      save: generate idempotent inactive xml for running domain · a8be259d
      Eric Blake 提交于
      Originally noticed by comparing the xml generated by virDomainSave
      with the xml produced by reparsing and redumping that xml, but I
      also did an audit of every last use of VIR_DOMAIN_XML_INACTIVE in
      domain_conf.c to ensure that no other discrepancies exist.
      
      * src/conf/domain_conf.c (virDomainDeviceInfoIsSet): Add
      parameter, and update all callers.  Make static.
      (virDomainNetDefFormat): Skip generated ifname.
      (virDomainDefFormatInternal): Skip default <seclabel>.
      (virDomainChrSourceDefParseXML): Skip generated pty path, and add
      parameter.  Update callers.
      * src/conf/domain_conf.h (virDomainDeviceInfoIsSet): Delete.
      * src/libvirt_private.syms (domain_conf.h): Update.
      a8be259d
    • E
      conf: make 'vnet' prefix a macro · dd20328f
      Eric Blake 提交于
      Using a macro ensures that all the code is looking for the same
      prefix.
      
      * src/conf/domain_conf.h (VIR_NET_GENERATED_PREFIX): New macro.
      * src/conf/domain_conf.c (virDomainNetDefParseXML): Use it.
      * src/uml/uml_conf.c (umlConnectTapDevice): Likewise.
      * src/qemu/qemu_command.c (qemuNetworkIfaceConnect): Likewise.
      Suggested by Laine Stump.
      dd20328f
    • L
      network: don't forward DNS requests from isolated networks · 513122ae
      Laine Stump 提交于
      This is in response to:
      
        https://bugzilla.redhat.com/show_bug.cgi?id=723862
      
      which points out that a guest on an "isolated" network could
      potentially exploit the DNS forwarding provided by dnsmasq to create a
      communication channel to the outside.
      
      This patch eliminates that possibility by adding the "--no-resolv"
      argument to the dnsmasq commandline, which tells dnsmasq to not
      forward on any requests that it can't resolve itself (by looking at
      its own static hosts files and runtime list of dhcp clients), but to
      instead return a failure for those requests.
      
      This shouldn't cause any undesirable change from current
      behavior, even in the case where a guest is currently configured with
      multiple interfaces, one of them being connected to an isolated
      network, and another to a network that does have connectivity to the
      outside. If the isolated network's DNS server is queried for a name
      it doesn't know, it will return "Refused" rather than "Unknown", which
      indicates to the guest that it should query other servers, so it then
      queries the connected DNS server, and gets the desired response.
      513122ae
    • E
      build: fix include path for cygwin · c5b6537b
      Eric Blake 提交于
      Without this, cygwin failed to compile:
      
      In file included from ../src/rpc/virnetmessage.h:24,
                       from ../src/rpc/virnetclient.h:27,
                       from remote/remote_driver.c:31:
      ../src/rpc/virnetprotocol.h:9:21: error: rpc/rpc.h: No such file or directory
      
      With that fixed, compilation warned:
      
      rpc/virnetsocket.c: In function 'virNetSocketNewListenUNIX':
      rpc/virnetsocket.c:347: warning: format '%d' expects type 'int', but argument 8 has type 'gid_t' [-Wformat]
      rpc/virnetsocket.c: In function 'virNetSocketGetLocalIdentity':
      rpc/virnetsocket.c:743: warning: pointer targets in passing argument 5 of 'getsockopt' differ in signedness
      
      * src/Makefile.am (libvirt_driver_remote_la_CFLAGS)
      (libvirt_net_rpc_client_la_CFLAGS)
      (libvirt_net_rpc_server_la_CFLAGS): Include XDR_CFLAGS, for rpc
      headers on cygwin.
      * src/rpc/virnetsocket.c (virNetSocketNewListenUNIX)
      (virNetSocketGetLocalIdentity): Avoid compiler warnings.
      c5b6537b
    • E
      build: avoid non-portable shell in test setup · 343ab982
      Eric Blake 提交于
      POSIX states that 'a=1; a=2 b=$a command' has unspecified results
      for the value of $b visible within command.  In particular, on
      BSD, this resulted in PATH not picking up the in-test ssh.
      
      * tests/Makefile.am (lv_abs_top_builddir): New macro.
      (path_add, TESTS_ENVIRONMENT): Use it to avoid referring to an
      environment variable set previously within the same command line.
      Reported by Matthias Bolte.
      343ab982
  3. 29 7月, 2011 15 次提交
    • M
      tests: Don't use bash if we don't have to · f2ac5807
      Matthias Bolte 提交于
      This tested failed on FreeBSD because it was using bash, that might
      not be installed.
      f2ac5807
    • O
      utils: More useful error message for hook script failure · ef765169
      Osier Yang 提交于
      Commit 3709a386 ported hooks codes to new command execution API,
      together with the useful error message removed. Though we can't
      get "errbuf" from the new command execution API anymore, still
      we can give a more useful error.
      
      https://bugzilla.redhat.com/show_bug.cgi?id=726398
      ef765169
    • M
      freebsd: Fix build problem due to picking up the wrong libvirt.h · b590866b
      Matthias Bolte 提交于
      Gettext annoyingly modifies CPPFLAGS in-place, putting
      -I/usr/local/include into the search patch if libintl headers
      must be used from that location.  But since we must support
      automake 1.9.6 which lacks AM_CPPFLAGS, and since CPPFLAGS is used
      prior to INCLUDES, this means that the build picks up the _old_
      installed libvirt.h in priority to the in-tree version, leading
      to all sorts of weird build failures on FreeBSD.
      
      Fix this by teaching configure to undo gettext's actions, but
      to keep any changes required by gettext at the end of INCLUDES
      after all in-tree locations are used first.  Also requires
      adding a wrapper Makefile.am and making gnulib-tool create
      just gnulib.mk files during the bootstrap process.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      b590866b
    • M
      freebsd: Avoid /bin/true in commandtest · c0e5994a
      Matthias Bolte 提交于
      Rely on PATH and use just true, because on FreeBSD it's /usr/bin/true.
      c0e5994a
    • M
      tests: Unify style of test skipping code · cffba7ea
      Matthias Bolte 提交于
      Prefer 'return EXIT_AM_SKIP' over 'exit(EXIT_AM_SKIP)'.
      
      Prefer 'int main(void)' over 'int main(int argc, char **argv)'.
      
      Fix mymain signature in commandtest and nodeinfotest.
      cffba7ea
    • E
      save: let qemu driver manipulate save files · f0a5eaf3
      Eric Blake 提交于
      The goal here is that save-image-dumpxml fed back to
      save-image-define should not change the save file; anywhere that
      this is not the case is probably a bug in domain_conf.c.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveImageGetXMLDesc)
      (qemuDomainSaveImageDefineXML): New functions.
      (qemuDomainSaveImageOpen): Add parameter.
      (qemuDomainRestoreFlags, qemuDomainObjRestore): Adjust clients.
      f0a5eaf3
    • E
      save: support qemu modifying xml on domain save/restore · 0ea479f8
      Eric Blake 提交于
      With this, it is possible to update the path to a disk backing
      image on either the save or restore action, without having to
      binary edit the XML embedded in the state file.
      
      This also modifies virDomainSave to output a smaller xml (only
      the inactive xml, which is all the more virDomainRestore parses),
      while still guaranteeing padding for most typical abi-compatible
      xml replacements, necessary so that the next patch for
      virDomainSaveImageDefineXML will not cause unnecessary
      modifications to the save image file.
      
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal): Add parameter,
      only use inactive state, and guarantee padding.
      (qemuDomainSaveImageOpen): Add parameter.
      (qemuDomainSaveFlags, qemuDomainManagedSave)
      (qemuDomainRestoreFlags, qemuDomainObjRestore): Update callers.
      0ea479f8
    • E
      maint: add missing copyright notices · ff81956a
      Eric Blake 提交于
      I went with the shorter license notice used by src/libvirt.c,
      rather than spelling out the full LGPLv2+ clause into each of
      these files.
      
      * configure.ac: Declare copyright.
      * all Makefile.am: Likewise.
      ff81956a
    • E
      xen: drop unused callbacks · 1b3765fd
      Eric Blake 提交于
      Found by:
      
      for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h)
      do
        git grep "\(\.\|->\)$f\b" src/xen
      done | cat
      
      and looking through the resulting list to see which callback struct
      members are still necessary.
      
      * src/xen/xen_driver.h (xenUnifiedDriver): Drop all callbacks that
      are only used directly.
      * src/xen/xen_hypervisor.c (xenHypervisorDriver): Shrink list.
      * src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
      * src/xen/xend_internal.c (xenDaemonDriver): Likewise.
      * src/xen/xm_internal.c (xenXMDriver): Likewise.
      * src/xen/xs_internal.c (xenStoreDriver): Likewise.
      1b3765fd
    • E
      xen: make direct call when there is only one subdriver · a1e641a5
      Eric Blake 提交于
      No need to use a for loop if we know there is exactly one client.
      Found by:
      
      for f in $(sed -n 's/.*Drv[^ ]* \([^;]*\);.*/\1/p' src/xen/xen_driver.h)
      do
        git grep "\(\.\|->\)$f\b" src/xen
      done | cat
      
      and looking through the resulting list to see which callback struct
      members are used exactly once.  The next patch will ensure that we
      don't reintroduce uses of these callbacks.
      
      * src/xen/xen_driver.c (xenUnifiedClose): Call close
      unconditionally, to match xenUnifiedOpen.
      (xenUnifiedNodeGetInfo, xenUnifiedDomainCreateXML)
      (xenUnifiedDomainSave, xenUnifiedDomainRestore)
      (xenUnifiedDomainCoreDump, xenUnifiedDomainUpdateDeviceFlags):
      Make direct call to lone implementation.
      * src/xen/xend_internal.h (xenDaemonDomainCoreDump)
      (xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Add prototypes.
      * src/xen/xend_internal.c (xenDaemonDomainCoreDump)
      (xenDaemonUpdateDeviceFlags, xenDaemonCreateXML): Export.
      a1e641a5
    • E
      xen: reduce callback special cases · 03e5f8bb
      Eric Blake 提交于
      The callback struct is great when iterating through several
      possibilities, but when calling a known callback, it's just
      overhead.  We can make the direct call in those cases.
      
      * src/xen/xen_driver.c (xenUnifiedOpen, xenUnifiedDomainSuspend)
      (xenUnifiedDomainResume, xenUnifiedDomainDestroyFlags): Make
      direct calls instead of going through callback.
      03e5f8bb
    • E
      xen: cleanup callback struct · f859919f
      Eric Blake 提交于
      Using C99 initializers and xen-specific prefixes will make it
      so that future patches are less likely to add callback members
      to the xenUnifiedDriver struct, since the goal is to get rid
      of the callback struct in the first place.
      
      * src/xen/xen_driver.h (xenUnifiedDriver): Rename all struct
      members, to make it obvious which ones are still in use.
      * src/xen/xen_driver.c: Update all callers.
      * src/xen/xen_hypervisor.c (xenHypervisorDriver): Rewrite with C99
      initializers.
      * src/xen/xend_internal.c (xenDaemonDriver): Likewise.
      * src/xen/xs_internal.c (xenStoreDriver): Likewise.
      * src/xen/xm_internal.c (xenXMDriver): Likewise.
      * src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
      f859919f
    • L
      libxl: fix build failure due to change in virDomainGraphicsDef · eb1e3143
      Laine Stump 提交于
      This failure was introduced by commit dacee3d, which removed
      listenAddr from the unions in virDomainGraphicsDef in favor of putting
      it in the address attribute of virDomainGraphicsListenDef.
      eb1e3143
    • L
      qemu: support type=network in domain graphics <listen> · 99e4b30b
      Laine Stump 提交于
      The domain XML now understands the <listen> subelement of its
      <graphics> element (including when listen type='network'), and the
      network driver has an internal API that will turn a network name into
      an IP address, so the final logical step is to put the glue into the
      qemu driver so that when it is starting up a domain, if it finds
      <listen type='network' network='xyz'/> in the XML, it will call the
      network driver to get an IPv4 address associated with network xyz, and
      tell qemu to listen for vnc (or spice) on that address rather than the
      default address (localhost).
      
      The motivation for this is that a large installation may want the
      guests' VNC servers listening on physical interfaces rather than
      localhost, so that users can connect directly from the outside; this
      requires sending qemu the appropriate IP address to listen on. But
      this address will of course be different for each host, and if a guest
      might be migrated around from one host to another, it's important that
      the guest's config not have any information embedded in it that is
      specific to one particular host. <listen type='network.../> can solve
      this problem in the following manner:
      
        1) on each host, define a libvirt network of the same name,
           associated with the interface on that host that should be used
           for listening (for example, a simple macvtap network: <forward
           mode='bridge' dev='eth0'/>, or host bridge network: <forward
           mode='bridge'/> <bridge name='br0'/>
      
        2) in the <graphics> element of each guest's domain xml, tell vnc to
           listen on the network name used in step 1:
      
           <graphics type='vnc' port='5922'>
             <listen type='network'network='example-net'/>
           </graphics>
      
      (all the above also applies for graphics type='spice').
      99e4b30b
    • L
      conf: add <listen> subelement to domain <graphics> element · ef79fb5b
      Laine Stump 提交于
      Once it's plugged in, the <listen> element will be an optional
      replacement for the "listen" attribute that graphics elements already
      have. If the <listen> element is type='address', it will have an
      attribute called 'address' which will contain an IP address or dns
      name that the guest's display server should listen on. If, however,
      type='network', the <listen> element should have an attribute called
      'network' that will be set to the name of a network configuration to
      get the IP address from.
      
      * docs/schemas/domain.rng: updated to allow the <listen> element
      
      * docs/formatdomain.html.in: document the <listen> element and its
        attributes.
      
      * src/conf/domain_conf.[hc]:
      
        1) The domain parser, formatter, and data structure are modified to
           support 0 or more <listen> subelements to each <graphics>
           element. The old style "legacy" listen attribute is also still
           accepted, and will be stored internally just as if it were a
           separate <listen> element. On output (i.e. format), the address
           attribute of the first <listen> element of type 'address' will be
           duplicated in the legacy "listen" attribute of the <graphic>
           element.
      
        2) The "listenAddr" attribute has been removed from the unions in
           virDomainGRaphicsDef for graphics types vnc, rdp, and spice.
           This attribute is now in the <listen> subelement (aka
           virDomainGraphicsListenDef)
      
        3) Helper functions were written to provide simple access
           (both Get and Set) to the listen elements and their attributes.
      
      * src/libvirt_private.syms: export the listen helper functions
      
      * src/qemu/qemu_command.c, src/qemu/qemu_hotplug.c,
        src/qemu/qemu_migration.c, src/vbox/vbox_tmpl.c,
        src/vmx/vmx.c, src/xenxs/xen_sxpr.c, src/xenxs/xen_xm.c
      
        Modify all these files to use the listen helper functions rather
        than directly referencing the (now missing) listenAddr
        attribute. There can be multiple <listen> elements to a single
        <graphics>, but the drivers all currently only support one, so all
        replacements of direct access with a helper function indicate index
        "0".
      
      * tests/* - only 3 of these are new files added explicitly to test the
        new <listen> element. All the others have been modified to reflect
        the fact that any legacy "listen" attributes passed in to the domain
        parse will be saved in a <listen> element (i.e. one of the
        virDomainGraphicsListenDefs), and during the domain format function,
        both the <listen> element as well as the legacy attributes will be
        output.
      ef79fb5b
  4. 28 7月, 2011 14 次提交
    • A
      virsh: avoid missing zero value judgement in cmdBlkiotune · 3f39a0bf
      Alex Jia 提交于
      * tools/virsh.c: fix missing zero value judgement in cmdBlkiotune and correct
        vshError information.
      
        when weight is equal to 0, the cmdBlkiotune will not raise any error information
        when judge weight value first time, and execute else branch to judge weight
        value again, strncpy(temp->field, VIR_DOMAIN_BLKIO_WEIGHT, sizeof(temp->field))
        will be not executed for ever. However, if and only if param->field is equal
        to VIR_DOMAIN_BLKIO_WEIGHT, underlying qemuDomainSetBlkioParameters function
        will check whether weight value is in range [100, 1000].
      
      * how to reproduce?
      
        % virsh blkiotune ${guestname} --weight 0
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      3f39a0bf
    • E
      build: avoid type-punning compiler warning · b240f966
      Eric Blake 提交于
      On RHEL 5, with gcc 4.1.2:
      
      rpc/virnetsaslcontext.c: In function 'virNetSASLSessionUpdateBufSize':
      rpc/virnetsaslcontext.c:396: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
      
      * src/rpc/virnetsaslcontext.c (virNetSASLSessionUpdateBufSize):
      Use a union to work around gcc warning.
      b240f966
    • E
      qemu: fix nested job with driver lock held · d9fcd17e
      Eric Blake 提交于
      qemuMigrationUpdateJobStatus (called in a loop by migration
      and save tasks) uses qemuDomainObjEnterMonitorWithDriver;
      however, that function ended up starting a nested job without
      releasing the driver.
      
      Since no one else is making nested calls, we can inline the
      internal functions to properly track driver_locked.
      
      * src/qemu/qemu_domain.h (qemuDomainObjBeginNestedJob)
      (qemuDomainObjBeginNestedJobWithDriver)
      (qemuDomainObjEndNestedJob): Drop unused prototypes.
      * src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal):
      Reflect driver lock to nested job.
      (qemuDomainObjBeginNestedJob)
      (qemuDomainObjBeginNestedJobWithDriver)
      (qemuDomainObjEndNestedJob): Drop unused functions.
      d9fcd17e
    • M
      qemu: Fix memory leak on metadata fetching · 09d7eba9
      Michal Privoznik 提交于
      As written in virStorageFileGetMetadataFromFD decription, caller
      must free metadata after use. Qemu driver miss this and therefore
      leak metadata which can grow to huge mem leak if somebody query
      for blockInfo a lot.
      09d7eba9
    • M
      c6a4c375
    • M
      libvirt.c: Update outdated description of flags · 867e7519
      Michal Privoznik 提交于
      Because we do support flags for virDomainSetBlkioParameters and
      virDomainGetBlkioParameters, update appropriate description as well.
      867e7519
    • H
      26fdb417
    • H
      9b382394
    • H
      python: add python binding for virDomainSetBlkioParameters · 3f08212c
      Hu Tao 提交于
      3f08212c
    • H
      python: add python binding for virDomainGetBlkioParameters · 9d5cef18
      Hu Tao 提交于
      9d5cef18
    • A
      virsh: fix memory leak in cmdVolPath code · 1768bf63
      Alex Jia 提交于
      * tools/virsh.c: avoid memory leak in cmdVolPath.
      * src/libvirt.c: Add doc for virStorageVolGetPath to tell one
        must free() the returned path after use.
      
      * how to reproduce?
      
      % dd if=/dev/zero of=/var/lib/libvirt/images/foo.img count=1 bs=10M
      % virsh pool-refresh default
      % valgrind -v --leak-check=full virsh vol-path --vol \
      /var/lib/libvirt/images/foo.img
      
      * actual results:
      
      Detected in valgrind run:
      
      ==16436== 32 bytes in 1 blocks are definitely lost in loss record 7 of 22
      ==16436==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
      ==16436==    by 0x386A314B3D: xdr_string (in /lib64/libc-2.12.so)
      ==16436==    by 0x3DF8CD770D: xdr_remote_nonnull_string (remote_protocol.c:3
      ==16436==    by 0x3DF8CD7EC8: xdr_remote_storage_vol_get_path_ret
      % virsh pool-refresh default
      % valgrind -v --leak-check=full virsh vol-path --vol \
      /var/lib/libvirt/images/foo.img
      Signed-off-by: NAlex Jia <ajia@redhat.com>
      1768bf63
    • O
      qemu: Improve docs for virsh dump format · 01e1ea12
      Osier Yang 提交于
      The error in getCompressionType will never be reported, change
      the errors codes into warning (VIR_WARN("%s", _(foo)); doesn't break
      syntax-check rule), and also improve the docs in qemu.conf to tell
      user the truth.
      01e1ea12
    • E
      qemu: improve thread documentation · 9a34ebd3
      Eric Blake 提交于
      * src/qemu/THREADS.txt: Fix problems with typos, grammar, and
      outdated examples.
      9a34ebd3
    • E
      virsh: expose change-protection during migration · 0d0bf850
      Eric Blake 提交于
      * tools/virsh.c (doMigrate): Add --change-protection flag.
      * tools/virsh.pod (migrate): Document it.
      0d0bf850