Re: [PATCH] kvm tools: adds a PCI device that exports a host shared segment as a PCI BAR in the guest

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 25, 2011 at 1:25 AM, David Evensky <evensky@xxxxxxxxxx> wrote:
> +       if (*next == '\0')
> +               p = next;
> +       else
> +               p = next + 1;
> +       /* parse out size */
> +       base = 10;
> +       if (strcasestr(p, "0x"))
> +               base = 16;
> +       size = strtoll(p, &next, base);
> +       if (next == p && size == 0) {
> +               pr_info("shmem: no size specified, using default.");
> +               size = default_size;
> +       }
> +       /* look for [KMGkmg][Bb]*  uses base 2. */
> +       int skip_B = 0;
> +       if (strspn(next, "KMGkmg")) {   /* might have a prefix */
> +               if (*(next + 1) == 'B' || *(next + 1) == 'b')
> +                       skip_B = 1;
> +               switch (*next) {
> +               case 'K':
> +               case 'k':
> +                       size = size << KB_SHIFT;
> +                       break;
> +               case 'M':
> +               case 'm':
> +                       size = size << MB_SHIFT;
> +                       break;
> +               case 'G':
> +               case 'g':
> +                       size = size << GB_SHIFT;
> +                       break;
> +               default:
> +                       die("shmem: bug in detecting size prefix.");
> +                       break;
> +               }

There's some nice code in perf to parse sizes like this. We could just
steal that.

> +inline void fill_mem(void *buf, size_t buf_size, char *fill, size_t fill_len)
> +{
> +       size_t i;
> +
> +       if (fill_len == 1) {
> +               memset(buf, fill[0], buf_size);
> +       } else {
> +               if (buf_size > fill_len) {
> +                       for (i = 0; i < buf_size - fill_len; i += fill_len)
> +                               memcpy(((char *)buf) + i, fill, fill_len);
> +                       memcpy(buf + i, fill, buf_size - i);
> +               } else {
> +                       memcpy(buf, fill, buf_size);
> +               }
> +       }
> +}

Can we do a memset_pattern4() type of interface instead? I think it's
mostly pointless to try to support arbitrary-length 'fill'.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux