1. 13 5月, 2013 22 次提交
    • D
      Fix error handling of readdir() in virFileLoopDeviceOpen · 1eeff53d
      Daniel P. Berrange 提交于
      To correctly handle errors from readdir() you must set 'errno'
      to zero before invoking it & check its value afterwards to
      distinguish error from EOF.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      1eeff53d
    • D
      Re-arrange code setting up ifs/disk loop devices for LXC · c8fa7e8c
      Daniel P. Berrange 提交于
      The current code for setting up loop devices to LXC disks first
      does a switch() based on the disk format, then looks at the
      disk driver name. Reverse this so it first looks at the driver
      name, and then the disk format. This is more useful since the
      list of supported disk formats depends on what driver is used.
      
      The code for setting loop devices for LXC fs entries also needs
      to have the same logic added, now the XML schema supports this.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      c8fa7e8c
    • D
      Add support for storage format in FS <driver> · ada14b86
      Daniel P. Berrange 提交于
      Extend the <driver> element in filesystem devices to
      allow a storage format to be set. The new attribute
      uses 'format' to reflect the storage format. This is
      different from the <driver> element in disk devices
      which use 'type' to reflect the storage format. This
      is because the 'type' attribute on filesystem devices
      is already used for the driver backend, for which the
      disk devices use the 'name' attribute. Arggggh.
      
      Anyway for disks we have
      
         <driver name="qemu" type="raw"/>
      
      And for filesystems this change means we now have
      
         <driver type="loop" format="raw"/>
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      ada14b86
    • M
      security_apparmor.c: Include virscsi.h · 23fbda20
      Michal Privoznik 提交于
      After introducing AppArmorSetSecuritySCSILabel() in 2691cd5f
      we are using virSCSIDevicePtr type without proper include.
      23fbda20
    • O
      security: Manage the security label for scsi host device · 2691cd5f
      Osier Yang 提交于
      To not introduce more redundant code, helpers are added for
      both "selinux", "dac", and "apparmor" backends.
      Signed-off-by: NHan Cheng <hanc.fnst@cn.fujitsu.com>
      Signed-off-by: NOsier Yang <jyang@redhat>
      
      v2.5 - v3:
        * Splitted from 8/10 of v2.5
        * Don't forget the other backends (DAC, and apparmor)
      2691cd5f
    • H
      qemu: Allow the scsi-generic device in cgroup · 6eb42e38
      Han Cheng 提交于
      This adds the scsi-generic device into the device controller's
      whitelist, so that it's allowed to used by the qemu process.
      Signed-off-by: NHan Cheng <hanc.fnst@cn.fujitsu.com>
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      6eb42e38
    • O
      qemu: Support bootindex for scsi host device · bab6ee6b
      Osier Yang 提交于
      bab6ee6b
    • D
      Add docs about cgroups layout and usage · 486a86eb
      Daniel P. Berrange 提交于
      Describe the new cgroups layout, how to customize placement
      of guests and what virsh commands are used to access the
      parameters.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      486a86eb
    • O
      Introduce <readonly> for hostdev · f4bb7b48
      Osier Yang 提交于
      Since it's generic enough to be used by other types in future, I
      put it in <hostdev> as sub-element, though now it's only used by
      scsi host device.
      f4bb7b48
    • O
      rng: Interleave hostdev elements · dcd632af
      Osier Yang 提交于
      dcd632af
    • H
      qemu: Build qemu command line for scsi host device · 0d70656a
      Han Cheng 提交于
      Except the scsi host device's controller is "lsilogic", mapping
      between the libvirt attributes and scsi-generic properties is:
      
        libvirt     qemu
      -----------------------------------------
        controller  bus ($libvirt_controller.0)
        bus         channel
        target      scsi-id
        unit        lun
      
      For scsi host device with "lsilogic" controller, the mapping is:
      ('target (libvirt)' must be 0, as it's not used; 'unit (libvirt)
      must <= 7).
      
        libvirt            qemu
      ----------------------------------------------------------
        controller && bus  bus ($libvirt_controller.$libvirt_bus)
        unit               scsi-id
      
      It's not good to hardcode/hard-check limits of these attributes,
      and even worse, these limits are not documented, one has to find
      out by either testing or reading the qemu code, I'm looking forward
      to qemu expose limits like these one day). For example, exposing
      "max_target", "max_lun" for megasas:
      
      static const struct SCSIBusInfo megasas_scsi_info = {
          .tcq = true,
          .max_target = MFI_MAX_LD,
          .max_lun = 255,
      
          .transfer_data = megasas_xfer_complete,
          .get_sg_list = megasas_get_sg_list,
          .complete = megasas_command_complete,
          .cancel = megasas_command_cancel,
      };
      
      Example of the qemu command line (lsilogic controller):
      
        -drive file=/dev/sg2,if=none,id=drive-hostdev-scsi_host7-0-0-0 \
        -device scsi-generic,bus=scsi0.0,scsi-id=8,\
        drive=drive-hostdev-scsi_host7-0-0-0,id=hostdev-scsi_host7-0-0-0
      
      Example of the qemu command line (virtio-scsi controller):
      
        -drive file=/dev/sg2,if=none,id=drive-hostdev-scsi_host7-0-0-0 \
        -device scsi-generic,bus=scsi0.0,channel=0,scsi-id=128,lun=128,\
        drive=drive-hostdev-scsi_host7-0-0-0,id=hostdev-scsi_host7-0-0-0
      Signed-off-by: NHan Cheng <hanc.fnst@cn.fujitsu.com>
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      0d70656a
    • H
      utils: util functions for scsi hostdev · 7486584c
      Han Cheng 提交于
      This patch adds util functions for scsi hostdev.
      Signed-off-by: NHan Cheng <hanc.fnst@cn.fujitsu.com>
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      7486584c
    • H
      qemu: New cap flags for scsi-generic · b238c0be
      Han Cheng 提交于
      Adding two cap flags for scsi-generic:
        QEMU_CAPS_SCSI_GENERIC
        QEMU_CAPS_SCSI_GENERIC_BOOTINDEX
      Signed-off-by: NHan Cheng <hanc.fnst@cn.fujitsu.com>
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      b238c0be
    • O
      node_device: Clean up unused macros · 9677ff08
      Osier Yang 提交于
      All of these macros are now unused, so remove.
      9677ff08
    • H
      conf: Generic XMLs for scsi hostdev · 5c811dce
      Han Cheng 提交于
      An example of the scsi hostdev XML:
      
          <hostdev mode='subsystem' type='scsi'>
            <source>
              <adapter name='scsi_host0'/>
              <address bus='0' target='0' unit='0'/>
            </source>
            <address type='drive' controller='0' bus='0' target='4' unit='8'/>
          </hostdev>
      
      Controller is implicitly added for scsi hostdev, though the scsi
      controller's model defaults to "lsilogic", which might be not what
      the user wants (same problem exists for virtio-scsi disk). It's
      the existing problem, will be addressed later.
      
      The device address must be specified manually. Later patch will let
      libvirt generate it automatically.
      
      This only introduces the generic XMLs for scsi hostdev, later patches
      will add other elements, e.g. <readonly>, <shareable>.
      Signed-off-by: NHan Cheng <hanc.fnst@cn.fujitsu.com>
      Signed-off-by: NOsier Yang <jyang@redhat.com>
      5c811dce
    • O
      tests: Add tests for fc_host · 9706d85f
      Osier Yang 提交于
      Since the NPIV machine is not easy to get, it's very likely to
      introduce regressions when doing changes on the existing code.
      This patch dumps part of the sysfs files (the necessary ones)
      of fc_host as test input data, to test the related util functions.
      It could be extended for more fc_host related testing in future.
      9706d85f
    • O
      util: Honor the passed sysfs_prefix · b7ab7195
      Osier Yang 提交于
      The helper works for default sysfs_prefix, but for user specified
      prefix, it doesn't work. (Detected when writing test cases. A later
      patch will add the test cases for fc_host).
      b7ab7195
    • O
      util: Update the comment for virGetFCHostNameByWWN · 1a59ae91
      Osier Yang 提交于
      The returned result is something like "host5" acutally.
      1a59ae91
    • O
      util: Change virIsCapable* to return bool · c56c273b
      Osier Yang 提交于
      Function name with "aIsB" generally means its return value is
      in Bi-state (true/false).
      c56c273b
    • O
      util: Don't miss the slash in constructed path · b595588f
      Osier Yang 提交于
      In case of the caller can pass a "prefix" (or "sysfs_prefix")
      without the trailing slash, and Unix-Like system always eats
      up the redundant "slash" in the filepath, let's add it explicitly.
      b595588f
    • O
      util: Fix regression introduced by commit 4360a098 · e106c011
      Osier Yang 提交于
      Which refactored the old code, and introduced new helper
      virIsCapableVport, but the path for checking with access() is not
      correctly constructed.
      e106c011
    • O
      util: Fix regression of wwn reading · b76284af
      Osier Yang 提交于
      Introduced by commit 244ce462, which refactored the helper for wwn
      reading, however, it forgot to change the old "strndup" and "sizeof(buf)",
      "sizeof(buf)" operates on the fixed length array ("buf") in the old code,
      but now "buf" is a pointer.
      
      Before the fix:
      
      % virsh nodedev-dumpxml scsi_host5
      <device>
        <name>scsi_host5</name>
        <parent>pci_0000_04_00_1</parent>
        <capability type='scsi_host'>
          <host>5</host>
          <capability type='fc_host'>
            <wwnn>2001001b</wwnn>
            <wwpn>2101001b</wwpn>
            <fabric_wwn>2001000d</fabric_wwn>
          </capability>
        </capability>
      </device>
      
      With the fix:
      
      % virsh nodedev-dumpxml scsi_host5
      <device>
        <name>scsi_host5</name>
        <parent>pci_0000_04_00_1</parent>
        <capability type='scsi_host'>
          <host>5</host>
          <capability type='fc_host'>
            <wwnn>0x2001001b32a9da4e</wwnn>
            <wwpn>0x2101001b32a9da4e</wwpn>
            <fabric_wwn>0x2001000dec9877c1</fabric_wwn>
          </capability>
        </capability>
      </device>
      b76284af
  2. 11 5月, 2013 11 次提交
    • E
      build: fix use of mmap · d34ef017
      Eric Blake 提交于
      Commit bfe7721d introduced a regression, but only on platforms
      like FreeBSD that lack posix_fallocate and where mmap serves as
      a nice fallback for safezero.
      
      util/virfile.c: In function 'safezero':
      util/virfile.c:837: error: 'PROT_READ' undeclared (first use in this function)
      
      * src/util/virutil.c (includes): Move use of <sys/mman.h>...
      * src/util/virfile.c (includes): ...to the file that uses mmap.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      d34ef017
    • E
      build: update to latest gnulib, for syntax-check · 12bd22c7
      Eric Blake 提交于
      This picks up a fix for a syntax-check weakness mentioned here:
      https://www.redhat.com/archives/libvir-list/2013-May/msg00811.html
      
      * .gnulib: Update to latest, for maint.mk improvement.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      12bd22c7
    • D
      Update hellolibvirt to demo virGetLastErrorMessage() · 0902f696
      Daniel P. Berrange 提交于
      Update the hellolibvirt example program to demonstrate use of
      the virGetLastErrorMessage() API for quick error reporting
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      0902f696
    • D
      Add a test case for the fdstream file read/write code · 31989e66
      Daniel P. Berrange 提交于
      Add a test case which exercises the virFDStreamOpenFile
      and virFDStreamCreateFile methods. Ensure that both the
      synchronous and non-blocking iohelper code paths work.
      This validates the regression recently fixed which
      broke reading in non-blocking mode
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      31989e66
    • D
      Allow the iohelper path to be customized by test programs · 8ab7d8ee
      Daniel P. Berrange 提交于
      Currently the fdstream function hardcodes the location
      of the iohelper to LIBEXECDIR "/libvirt_iohelper". This
      is not convenient when trying to write test cases which
      use this code. Add a virFDStreamSetIOHelper method to
      allow the test cases to point to the location of the
      un-installed iohelper binary.
      Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
      8ab7d8ee
    • 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
  3. 10 5月, 2013 7 次提交