1. 11 5月, 2013 6 次提交
    • D
      Add a virGetLastErrorMessage() function · 69c6a58a
      Daniel P. Berrange 提交于
      Apps using libvirt will often have code like
      
         if (virXXXX() < 0) {
            virErrorPtr err = virGetLastError();
            fprintf(stderr, "Something failed: %s\n",
                    err && err->message ? err->message :
                    "unknown error");
            return -1;
         }
      
      Checking for a NULL error object or message leads to very
      verbose code. A virGetLastErrorMessage() helper from libvirt
      can simplify this to
      
         if (virXXXX() < 0) {
            fprintf(stderr, "Something failed: %s\n",
                    virGetLastErrorMessage());
            return -1;
         }
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      69c6a58a
    • D
      Fix iohelper usage with streams opened for read · a2214c52
      Daniel P. Berrange 提交于
      In b2878ed8 we added the O_NOCTTY
      flag when opening files in the stream code. Unfortunately a later
      piece of code was comparing the flags == O_RDONLY, without masking
      out the non-access mode flags. This broke the iohelper when used
      with streams for read, since it caused us to attach the stream
      output pipe to the stream input FD instead of output FD :-(
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      a2214c52
    • D
      Cope with missing swap cgroup controls · f493d83f
      Daniel P. Berrange 提交于
      It is possible to build a kernel without swap cgroup controls
      present. This causes a fatal error when querying memory
      parameters. Treat missing swap controls as meaning "unlimited".
      The fatal error remains if the user tries to actually change
      the limit.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      f493d83f
    • R
      portability: fix virNetDevSetMAC and virNetDevExists on BSD · 95934171
      Roman Bogorodskiy 提交于
      - provide virNetDevSetMAC() implementation based on SIOCSIFLLADDR
        ioctl.
      - adjust virNetDevExists() to check for ENXIO error because
        FreeBSD throws it when device doesn't exist
      Signed-off-by: NEric Blake <eblake@redhat.com>
      95934171
    • L
      util: move virFile* functions from virutil.c to virfile.c · bfe7721d
      Laine Stump 提交于
      These all existed before virfile.c was created, and for some reason
      weren't moved.
      
      This is mostly straightfoward, although the syntax rule prohibiting
      write() had to be changed to have an exception for virfile.c instead
      of virutil.c.
      
      This movement pointed out that there is a function called
      virBuildPath(), and another almost identical function called
      virFileBuildPath(). They really should be a single function, which
      I'll take care of as soon as I figure out what the arglist should look
      like.
      bfe7721d
    • L
      util: fix virFileOpenAs return value and resulting error logs · a2c1bedb
      Laine Stump 提交于
      This resolves:
      
           https://bugzilla.redhat.com/show_bug.cgi?id=851411
           https://bugzilla.redhat.com/show_bug.cgi?id=955500
      
      The first problem was that virFileOpenAs was returning fd (-1) in one
      of the error cases rather than ret (-errno), so the caller thought
      that the error was EPERM rather than ENOENT.
      
      The second problem was that some log messages in the general purpose
      qemuOpenFile() function would always say "Failed to create" even if
      the caller hadn't included O_CREAT (i.e. they were trying to open an
      existing file).
      
      This fixes virFileOpenAs to jump down to the error return (which
      returns ret instead of fd) in the previously mentioned incorrect
      failure case of virFileOpenAs(), removes all error logging from
      virFileOpenAs() (since the callers report it), and modifies
      qemuOpenFile to appropriately use "open" or "create" in its log
      messages.
      
      NB: I seriously considered removing logging from all callers of
      virFileOpenAs(), but there is at least one case where the caller
      doesn't want virFileOpenAs() to log any errors, because it's just
      going to try again (qemuOpenFile()). We can't simply make a silent
      variation of virFileOpenAs() though, because qemuOpenFile() can't make
      the decision about whether or not it wants to retry until after
      virFileOpenAs() has already returned an error code.
      
      Likewise, I also considered changing virFileOpenAs() to return -1 with
      errno set on return, and may still do that, but only as a separate
      patch, as it obscures the intent of this patch too much.
      a2c1bedb
  2. 10 5月, 2013 18 次提交
  3. 09 5月, 2013 16 次提交