1. 04 8月, 2011 2 次提交
    • E
      build: update to latest gnulib · 02eab9ce
      Eric Blake 提交于
      I noticed that with 0.9.4, gnulib ended up replacing pthread_sigmask
      on glibc, even though glibc's works perfectly fine.  It turns out
      to have been an upstream gnulib bug.
      
      * .gnulib: Update to latest, for pthread_sigmask fix.
      02eab9ce
    • M
      Fix detection of GnuTLS 1.x.y · 099d30a8
      Matthias Bolte 提交于
      Detection based on gnutls_session doesn't work because GnuTLS 2.x.y
      comes with a compat.h that defines gnutls_session to gnutls_session_t.
      
      Instead detect this based on LIBGNUTLS_VERSION_MAJOR. Move this from
      configure/config.h to gnutls_1_0_compat.h and make sure that all users
      include gnutls_1_0_compat.h properly.
      
      Also fix header guard in gnutls_1_0_compat.h.
      099d30a8
  2. 03 8月, 2011 22 次提交
    • D
      Release of libvirt-0.9.4 · 14c2ca3d
      Daniel Veillard 提交于
      * configure.ac docs/news.html.in libvirt.spec.in: updates for new
        release
      * po/*.po*: pulled translations from the transifex teams and regenerated
        localizations
      14c2ca3d
    • E
      qemu: silence coverity false positives · f768b4c3
      Eric Blake 提交于
      Coverity gets confused by our logic.  Add some hints to silence
      false positives.
      
      * src/qemu/qemu_driver.c (qemudDomainGetVcpuPinInfo): Add hint.
      (qemuDomainGetMemoryParameters): Likewise.
      f768b4c3
    • E
      util: plug memory leak · c86827a2
      Eric Blake 提交于
      Leak detected by Coverity; only possible on unlikely ptsname_r
      failure.  Additionally, the man page for ptsname_r states that
      failure is merely non-zero, not necessarily -1.
      
      * src/util/util.c (virFileOpenTtyAt): Avoid leak on ptsname_r
      failure.
      c86827a2
    • E
      interface: drop dead code · d69b79ab
      Eric Blake 提交于
      Coverity detected that ifaceGetNthParent had already dereferenced
      'nth' prior to the conditional; all callers already complied with
      passing a non-NULL pointer so make this part of the contract.
      
      * src/util/interface.h (ifaceGetNthParent): Add annotations.
      * src/util/interface.c (ifaceGetNthParent): Drop useless null check.
      d69b79ab
    • E
      rpc: silence coverity false positives · 0634b623
      Eric Blake 提交于
      In virNetServerNew, Coverity didn't realize that srv->mdsnGroupName
      can only be non-NULL if mdsnGroupName was non-NULL.
      
      In virNetServerRun, Coverity didn't realize that the array is non-NULL
      if the array count is non-zero.
      
      * src/rpc/virnetserver.c (virNetServerNew): Use alternate pointer.
      (virNetServerRun): Give coverity a hint.
      0634b623
    • E
      rpc: avoid null deref · 8d0be8fd
      Eric Blake 提交于
      Detected by Coverity.
      
      * src/rpc/virnetserverclient.c (virNetServerClientDispatchRead):
      Avoid null deref on OOM.
      8d0be8fd
    • E
      build: silence coverity false positives · 44ebb18e
      Eric Blake 提交于
      Coverity complained that 395 out of 409 virAsprintf calls are
      checked, and therefore assumed that the remaining cases are bugs
      waiting to happen.  But in each of these cases, a failed virAsprintf
      will properly set the target string to NULL, and pass on that
      failure to the caller, without wasting efforts to check the call.
      Adding the ignore_value silences Coverity.
      
      * src/conf/domain_audit.c (virDomainAuditGetRdev): Ignore
      virAsprintf return value, when it behaves like we need.
      * src/network/bridge_driver.c (networkDnsmasqLeaseFileNameDefault)
      (networkRadvdConfigFileName, networkBridgeDummyNicName)
      (networkRadvdPidfileBasename): Likewise.
      * src/util/storage_file.c (absolutePathFromBaseFile): Likewise.
      * src/openvz/openvz_driver.c (openvzGenerateContainerVethName):
      Likewise.
      * src/util/command.c (virCommandTranslateStatus): Likewise.
      44ebb18e
    • E
      qemu: avoid memory leaks · 2ea9409a
      Eric Blake 提交于
      Quite a few leaks detected by coverity.  For chr, the leaks were
      close enough to the allocations to plug in place; for disk, the
      leaks were separated from the allocation by enough other lines with
      intermediate failure cases that I refactored the cleanup instead.
      
      * src/qemu/qemu_command.c (qemuParseCommandLine): Plug leaks.
      2ea9409a
    • E
      qemu: plug child process leak on domain core dump · 0c1813f4
      Eric Blake 提交于
      Detected by Coverity.  Leak introduced by typo in commit 58e668d2.
      
      * src/qemu/qemu_driver.c (doCoreDump): Use correct function.
      0c1813f4
    • E
      qemu: remove dead code · 9a87657a
      Eric Blake 提交于
      Warning detected by Coverity.  No need for the NULL check, and
      removing it silences the warning without any semantic change.
      
      * src/qemu/qemu_migration.c (qemuMigrationFinish): All entries to
      endjob had non-NULL vm.
      9a87657a
    • E
      conf: avoid memory leak on disk operations · 57ec8ced
      Eric Blake 提交于
      Detected by Coverity.  Leak on meta introduced in commit 85aa40e2.
      
      * src/conf/domain_conf.c (virDomainDiskDefForeachPath): Plug leak.
      57ec8ced
    • E
      rpc: avoid crash on error · ed246fbb
      Eric Blake 提交于
      Detected by Coverity.  Freeing the wrong variable results in both
      a memory leak and the likelihood of the caller dereferencing through
      a freed pointer.
      
      * src/rpc/virnettlscontext.c (virNetTLSSessionNew): Free correct
      variable.
      ed246fbb
    • E
      qemu: avoid null deref on block pull error · 9160573d
      Eric Blake 提交于
      Coverity detected that 5 of 6 callers of virJSONValueArrayGet checked
      for a NULL return; and that by not checking we risk a null deref
      during an error.  The error is unlikely since the prior call to
      virJSONValueArraySize would probably have already caught any botched
      JSON array parse, but better safe than sorry.
      
      * src/qemu/qemu_monitor_json.c (qemuMonitorJSONGetBlockJobInfo):
      Check for NULL.
      (qemuMonitorJSONExtractPtyPaths): Fix typo.
      9160573d
    • E
      rpc: correctly process sasl whitelist globs · 94b5dae4
      Eric Blake 提交于
      Detected by Coverity.  We want to compare the result of fnmatch 'rv',
      not our pre-set return value 'ret'.
      
      * src/rpc/virnetsaslcontext.c (virNetSASLContextCheckIdentity):
      Check correct variable.
      94b5dae4
    • E
      build: allow caching the input to STATIC_ANALYSIS · e4047f0a
      Eric Blake 提交于
      Right now, every re-run of configure re-evaluates whether a
      static analysis tool is in use.  But if you run configure under
      coverity, make a tweak, and then do an incremental rebuild with
      gcc but not coverity to test the tweak, then rerun a build under
      coverity, then configure does not get rerun, and static analysis
      ends up with lots of false positives.
      
      This patch caches the static analysis result, and also makes it
      easier to force static analysis even if the existing checks are
      insufficient to detect newer versions of the static analyzer tools.
      
      * configure.ac (lv_cv_static_analysis): New cache variable.
      e4047f0a
    • E
      fdstream: drop delete argument · 00ef048f
      Eric Blake 提交于
      Revert 6a1f5f56.  Now that libvirt_iohelper takes fds by
      inheritance rather than by open() (commit 1eb66479), there is
      no longer a race where the parent can unlink() a file prior to
      the iohelper open()ing the same file.  From there, it makes
      more sense to have the callers both create and unlink, rather
      than the caller create and the stream unlink, since the latter
      was only needed when iohelper had to do the unlink.
      
      * src/fdstream.h (virFDStreamOpenFile, virFDStreamCreateFile):
      Callers are responsible for deletion.
      * src/fdstream.c (virFDStreamOpenFileInternal): Don't leak created
      file on failure.
      (virFDStreamOpenFile, virFDStreamCreateFile): Drop parameter.
      * src/lxc/lxc_driver.c (lxcDomainOpenConsole): Update callers.
      * src/qemu/qemu_driver.c (qemuDomainScreenshot)
      (qemuDomainOpenConsole): Likewise.
      * src/storage/storage_driver.c (storageVolumeDownload)
      (storageVolumeUpload): Likewise.
      * src/uml/uml_driver.c (umlDomainOpenConsole): Likewise.
      * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Likewise.
      * src/xen/xen_driver.c (xenUnifiedDomainOpenConsole): Likewise.
      00ef048f
    • E
      screenshot: don't unlink bogus file · 440d6b6a
      Eric Blake 提交于
      The previous qemu patch could end up calling unlink(tmp) before
      tmp was the name of a valid file (unlinking a fileXXXXXX template
      instead), or calling unlink(tmp) twice on success (once here,
      and once at the end of the stream).  Meanwhile, vbox also suffered
      from the same leaked tmp file bug.
      
      * src/qemu/qemu_driver.c (qemuDomainScreenshot): Don't unlink on
      success, or on invalid name.
      * src/vbox/vbox_tmpl.c (vboxDomainScreenshot): Don't leak temp file.
      440d6b6a
    • E
      python: avoid unlikely sign extension bug · 69154397
      Eric Blake 提交于
      Detected by Coverity; same analysis as for commit f73198df.
      
      * python/libvirt-override.c (libvirt_virDomainGetVcpuPinInfo): Use
      correct type.
      69154397
    • E
      rpc: avoid uninitialized memory use · 3157d78f
      Eric Blake 提交于
      Spotted by Coverity.  Gnutls documents that buffer must be NULL
      if gnutls_x509_crt_get_key_purpose_oid is to be used to determine
      the correct size needed for allocating a buffer.
      
      * src/rpc/virnettlscontext.c
      (virNetTLSContextCheckCertKeyPurpose): Initialize buffer.
      3157d78f
    • E
      rpc: avoid double close on error · 50ae1de2
      Eric Blake 提交于
      Spotted by coverity.  If pipe2 fails, then we attempt to close
      uninitialized fds, which may result in a double-close.
      
      * src/rpc/virnetserver.c (virNetServerSignalSetup): Initialize fds.
      50ae1de2
    • M
      qemu: Unlink temporary file on failure · d68b97c8
      Michal Privoznik 提交于
      Although virFDStreamOpenFile will unlink it once opened, when we hit
      error path, we must unlink it by hand.
      d68b97c8
    • E
      doc: fix confusing statement about required privileges · de5494d8
      Eric Blake 提交于
      src/libvirt.c: "may requires" is confusing; the s was extra.
      de5494d8
  3. 02 8月, 2011 4 次提交
    • E
      rpc: avoid libvirtd crash on unexpected client close · 4e006b84
      Eric Blake 提交于
      Steps to reproduce this problem (vm1 is not running):
      for i in `seq 50`; do virsh managedsave vm1& done; killall virsh
      
      Pre-patch, virNetServerClientClose could end up setting client->sock
      to NULL prior to other cleanup functions trying to use client->sock.
      This fixes things by checking for NULL in more places, and by deferring
      the cleanup until after all queued messages have been served.
      
      * src/rpc/virnetserverclient.c (virNetServerClientRegisterEvent)
      (virNetServerClientGetFD, virNetServerClientIsSecure)
      (virNetServerClientLocalAddrString)
      (virNetServerClientRemoteAddrString): Check for closed socket.
      (virNetServerClientClose): Rearrange close sequence.
      Analysis from Wen Congyang.
      4e006b84
    • A
      virsh: fix memory leak in cmdNetworkInfo · 22da8c94
      Alex Jia 提交于
      * tools/virsh.c: avoid memory leak in cmdNetworkInfo.
      
      * how to reproduce?
        % valgrind -v --leak-check=yes virsh net-info default
      
        https://bugzilla.redhat.com/show_bug.cgi?id=722806Signed-off-by: NAlex Jia <ajia@redhat.com>
      22da8c94
    • A
      doc: fix incorrect option in blockjob · df971077
      Alex Jia 提交于
      * tools/virsh.pod: change 'live' to 'abort' based on actual option
      df971077
    • J
      openvz: detect when a domain was shut down from the inside · 082bcf1c
      Jean-Baptiste Rouault 提交于
      This patch adds an internal function openvzGetVEStatus to
      get the real state of the domain. This function is used in
      various places in the driver, in particular to detect when
      the domain has been shut down by the user with the "halt"
      command.
      082bcf1c
  4. 01 8月, 2011 7 次提交
    • E
      qemu: fix crash when mixing sync and async monitor jobs · 193cd0f3
      Eric Blake 提交于
      Currently, we attempt to run sync job and async job at the same time. It
      means that the monitor commands for two jobs can be run in any order.
      
      In the function qemuDomainObjEnterMonitorInternal():
          if (priv->job.active == QEMU_JOB_NONE && priv->job.asyncJob) {
              if (qemuDomainObjBeginNestedJob(driver, obj) < 0)
      We check whether the caller is an async job by priv->job.active and
      priv->job.asynJob. But when an async job is running, and a sync job is
      also running at the time of the check, then priv->job.active is not
      QEMU_JOB_NONE. So we cannot check whether the caller is an async job
      in the function qemuDomainObjEnterMonitorInternal(), and must instead
      put the burden on the caller to tell us when an async command wants
      to do a nested job.
      
      Once the burden is on the caller, then only async monitor enters need
      to worry about whether the VM is still running; for sync monitor enter,
      the internal return is always 0, so lots of ignore_value can be dropped.
      
      * src/qemu/THREADS.txt: Reflect new rules.
      * src/qemu/qemu_domain.h (qemuDomainObjEnterMonitorAsync): New
      prototype.
      * src/qemu/qemu_process.h (qemuProcessStartCPUs)
      (qemuProcessStopCPUs): Add parameter.
      * src/qemu/qemu_migration.h (qemuMigrationToFile): Likewise.
      (qemuMigrationWaitForCompletion): Make static.
      * src/qemu/qemu_domain.c (qemuDomainObjEnterMonitorInternal): Add
      parameter.
      (qemuDomainObjEnterMonitorAsync): New function.
      (qemuDomainObjEnterMonitor, qemuDomainObjEnterMonitorWithDriver):
      Update callers.
      * src/qemu/qemu_driver.c (qemuDomainSaveInternal)
      (qemudDomainCoreDump, doCoreDump, processWatchdogEvent)
      (qemudDomainSuspend, qemudDomainResume, qemuDomainSaveImageStartVM)
      (qemuDomainSnapshotCreateActive, qemuDomainRevertToSnapshot):
      Likewise.
      * src/qemu/qemu_process.c (qemuProcessStopCPUs)
      (qemuProcessFakeReboot, qemuProcessRecoverMigration)
      (qemuProcessRecoverJob, qemuProcessStart): Likewise.
      * src/qemu/qemu_migration.c (qemuMigrationToFile)
      (qemuMigrationWaitForCompletion, qemuMigrationUpdateJobStatus)
      (qemuMigrationJobStart, qemuDomainMigrateGraphicsRelocate)
      (doNativeMigrate, doTunnelMigrate, qemuMigrationPerformJob)
      (qemuMigrationPerformPhase, qemuMigrationFinish)
      (qemuMigrationConfirm): Likewise.
      * src/qemu/qemu_hotplug.c: Drop unneeded ignore_value.
      193cd0f3
    • 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
  5. 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