[virt-tools-list] [PATCH] Drop GSlice usage
--- src/gbinding.c | 4 ++-- src/virt-viewer-util.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gbinding.c b/src/gbinding.c index 4b2f5b1..a090015 100644 --- a/src/gbinding.c +++ b/src/gbinding.c @@ -1149,7 +1149,7 @@ bind_with_closures_free_func (gpointer data) if (t_data->transform_from_closure != NULL) g_closure_unref (t_data->transform_from_closure); - g_slice_free (TransformData, t_data); + g_free (t_data); } /** @@ -1191,7 +1191,7 @@ g_object_bind_property_with_closures (gpointer source, { TransformData *data; - data = g_slice_new0 (TransformData); + data = g_new0 (TransformData, 1); if (transform_to != NULL) { diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c index f2ccd13..c6bef1b 100644 --- a/src/virt-viewer-util.c +++ b/src/virt-viewer-util.c @@ -173,7 +173,7 @@ static WeakHandlerCtx * whc_new(GObject *instance, GObject *observer) { -WeakHandlerCtx *ctx = g_slice_new0(WeakHandlerCtx); +WeakHandlerCtx *ctx = g_new0(WeakHandlerCtx, 1); ctx->instance = instance; ctx->observer = observer; @@ -184,7 +184,7 @@ whc_new(GObject *instance, static void whc_free(WeakHandlerCtx *ctx) { -g_slice_free(WeakHandlerCtx, ctx); +g_free(ctx); } static void observer_destroyed_cb(gpointer, GObject *); -- 2.5.0 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH] Drop GSlice usage
Hi, Ack if you add some explanation to the commit log. Thanks, Pavel On Mon, 2016-01-18 at 10:04 +0100, Fabiano Fidêncio wrote: > --- > src/gbinding.c | 4 ++-- > src/virt-viewer-util.c | 4 ++-- > 2 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/src/gbinding.c b/src/gbinding.c > index 4b2f5b1..a090015 100644 > --- a/src/gbinding.c > +++ b/src/gbinding.c > @@ -1149,7 +1149,7 @@ bind_with_closures_free_func (gpointer data) > if (t_data->transform_from_closure != NULL) > g_closure_unref (t_data->transform_from_closure); > > - g_slice_free (TransformData, t_data); > + g_free (t_data); > } > > /** > @@ -1191,7 +1191,7 @@ g_object_bind_property_with_closures > (gpointer source, > { > TransformData *data; > > - data = g_slice_new0 (TransformData); > + data = g_new0 (TransformData, 1); > > if (transform_to != NULL) > { > diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c > index f2ccd13..c6bef1b 100644 > --- a/src/virt-viewer-util.c > +++ b/src/virt-viewer-util.c > @@ -173,7 +173,7 @@ static WeakHandlerCtx * > whc_new(GObject *instance, > GObject *observer) > { > -WeakHandlerCtx *ctx = g_slice_new0(WeakHandlerCtx); > +WeakHandlerCtx *ctx = g_new0(WeakHandlerCtx, 1); > > ctx->instance = instance; > ctx->observer = observer; > @@ -184,7 +184,7 @@ whc_new(GObject *instance, > static void > whc_free(WeakHandlerCtx *ctx) > { > -g_slice_free(WeakHandlerCtx, ctx); > +g_free(ctx); > } > > static void observer_destroyed_cb(gpointer, GObject *); ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH] Drop GSlice usage
Pavel, On Mon, Jan 18, 2016 at 10:14 AM, Pavel Grunt wrote: > Hi, > > Ack if you add some explanation to the commit log. "It's being slowly deprecated im glib https://bugzilla.gnome.org/show_bug.cgi?id=754687"; That would be the commit log, but I forgot to add before sending. Is it okay for you? > > Thanks, > Pavel > > On Mon, 2016-01-18 at 10:04 +0100, Fabiano Fidêncio wrote: >> --- >> src/gbinding.c | 4 ++-- >> src/virt-viewer-util.c | 4 ++-- >> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> diff --git a/src/gbinding.c b/src/gbinding.c >> index 4b2f5b1..a090015 100644 >> --- a/src/gbinding.c >> +++ b/src/gbinding.c >> @@ -1149,7 +1149,7 @@ bind_with_closures_free_func (gpointer data) >>if (t_data->transform_from_closure != NULL) >> g_closure_unref (t_data->transform_from_closure); >> >> - g_slice_free (TransformData, t_data); >> + g_free (t_data); >> } >> >> /** >> @@ -1191,7 +1191,7 @@ g_object_bind_property_with_closures >> (gpointer source, >> { >>TransformData *data; >> >> - data = g_slice_new0 (TransformData); >> + data = g_new0 (TransformData, 1); >> >>if (transform_to != NULL) >> { >> diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c >> index f2ccd13..c6bef1b 100644 >> --- a/src/virt-viewer-util.c >> +++ b/src/virt-viewer-util.c >> @@ -173,7 +173,7 @@ static WeakHandlerCtx * >> whc_new(GObject *instance, >> GObject *observer) >> { >> -WeakHandlerCtx *ctx = g_slice_new0(WeakHandlerCtx); >> +WeakHandlerCtx *ctx = g_new0(WeakHandlerCtx, 1); >> >> ctx->instance = instance; >> ctx->observer = observer; >> @@ -184,7 +184,7 @@ whc_new(GObject *instance, >> static void >> whc_free(WeakHandlerCtx *ctx) >> { >> -g_slice_free(WeakHandlerCtx, ctx); >> +g_free(ctx); >> } >> >> static void observer_destroyed_cb(gpointer, GObject *); > > ___ > virt-tools-list mailing list > virt-tools-list@redhat.com > https://www.redhat.com/mailman/listinfo/virt-tools-list -- Fabiano Fidêncio ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH] Drop GSlice usage
On Mon, Jan 18, 2016 at 10:45:17AM +0100, Fabiano Fidêncio wrote: > Pavel, > > On Mon, Jan 18, 2016 at 10:14 AM, Pavel Grunt wrote: > > Hi, > > > > Ack if you add some explanation to the commit log. > > "It's being slowly deprecated im glib > https://bugzilla.gnome.org/show_bug.cgi?id=754687"; > > That would be the commit log, but I forgot to add before sending. > Is it okay for you? 'in glib', not 'im glib', looks fine otherwise. Christophe signature.asc Description: PGP signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [PATCH] Drop GSlice usage
On Mon, 2016-01-18 at 10:45 +0100, Fabiano Fidêncio wrote: > Pavel, > > On Mon, Jan 18, 2016 at 10:14 AM, Pavel Grunt > wrote: > > Hi, > > > > Ack if you add some explanation to the commit log. > > "It's being slowly deprecated im glib > https://bugzilla.gnome.org/show_bug.cgi?id=754687"; > > That would be the commit log, but I forgot to add before sending. > Is it okay for you? > Yes, it is. Thanks! > > > > Thanks, > > Pavel > > > > On Mon, 2016-01-18 at 10:04 +0100, Fabiano Fidêncio wrote: > > > --- > > > src/gbinding.c | 4 ++-- > > > src/virt-viewer-util.c | 4 ++-- > > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > > > diff --git a/src/gbinding.c b/src/gbinding.c > > > index 4b2f5b1..a090015 100644 > > > --- a/src/gbinding.c > > > +++ b/src/gbinding.c > > > @@ -1149,7 +1149,7 @@ bind_with_closures_free_func (gpointer > > > data) > > > if (t_data->transform_from_closure != NULL) > > > g_closure_unref (t_data->transform_from_closure); > > > > > > - g_slice_free (TransformData, t_data); > > > + g_free (t_data); > > > } > > > > > > /** > > > @@ -1191,7 +1191,7 @@ g_object_bind_property_with_closures > > > (gpointer source, > > > { > > > TransformData *data; > > > > > > - data = g_slice_new0 (TransformData); > > > + data = g_new0 (TransformData, 1); > > > > > > if (transform_to != NULL) > > > { > > > diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c > > > index f2ccd13..c6bef1b 100644 > > > --- a/src/virt-viewer-util.c > > > +++ b/src/virt-viewer-util.c > > > @@ -173,7 +173,7 @@ static WeakHandlerCtx * > > > whc_new(GObject *instance, > > > GObject *observer) > > > { > > > -WeakHandlerCtx *ctx = g_slice_new0(WeakHandlerCtx); > > > +WeakHandlerCtx *ctx = g_new0(WeakHandlerCtx, 1); > > > > > > ctx->instance = instance; > > > ctx->observer = observer; > > > @@ -184,7 +184,7 @@ whc_new(GObject *instance, > > > static void > > > whc_free(WeakHandlerCtx *ctx) > > > { > > > -g_slice_free(WeakHandlerCtx, ctx); > > > +g_free(ctx); > > > } > > > > > > static void observer_destroyed_cb(gpointer, GObject *); > > > > ___ > > virt-tools-list mailing list > > virt-tools-list@redhat.com > > https://www.redhat.com/mailman/listinfo/virt-tools-list > > > ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH RFC virtio-win-pkg-scripts 2/2] add script to lay out drivers based on their catalog files
This script recursively discovers the driver packages (that is, a directory containing an .inf file, an .cat file, and possibly other files) in the source directory. For each such package, it parses the catalog file and determines what architectures and windows flavors this driver is suitable for. Then it copies or links the driver into appropriate subdirectories of the destination directory. As a byproduct it also verifies signatures where it can. The resulting structure is supposed to be convenient for consupmtion by both humans and programs. Signed-off-by: Roman Kagan --- util/cpdrivers.py | 191 ++ 1 file changed, 191 insertions(+) create mode 100644 util/cpdrivers.py diff --git a/util/cpdrivers.py b/util/cpdrivers.py new file mode 100644 index 000..9398f80 --- /dev/null +++ b/util/cpdrivers.py @@ -0,0 +1,191 @@ +#!/usr/bin/python +# +# Copyright 2016 Parallels IP Holdings GmbH +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +""" +Recurse the source directory and, for every subdirectory containing a windows +driver (i.e. an .inf, an .cat, and a few other files), copy or link it into a +subdirectory corresponding to the arch/os flavor the driver is suitable for. + +The suitability is based on the info extracted from the .cat file, so +re-signing affects that as expected. +""" + +import os, sys, hashlib, struct, mmap, shutil +from optparse import OptionParser +from parsecat import parseCat + +osMap = { +'XPX86':( '5.1','x86', 'xp' ), +'XPX64':( '5.2', 'amd64', 'xp' ), +'Server2003X86':( '5.2','x86', '2k3'), +'Server2003X64':( '5.2', 'amd64', '2k3'), +'VistaX86': ( '6.0','x86', 'vista' ), +'VistaX64': ( '6.0', 'amd64', 'vista' ), +'Server2008X86':( '6.0','x86', '2k8'), +'Server2008X64':( '6.0', 'amd64', '2k8'), +'7X86': ( '6.1','x86', 'w7' ), +'7X64': ( '6.1', 'amd64', 'w7' ), +'Server2008R2X64': ( '6.1', 'amd64', '2k8R2' ), +'8X86': ( '6.2','x86', 'w8' ), +'8X64': ( '6.2', 'amd64', 'w8' ), +'Server2012X64':( '6.2', 'amd64', '2k12' ), +'_v63': ( '6.3','x86', 'w8.1' ), +'_v63_X64': ( '6.3', 'amd64', 'w8.1' ), +'_v63_Server_X64': ( '6.3', 'amd64', '2k12R2' ), +'_v100':('10.0','x86', 'w10'), +'_v100_X64':('10.0', 'amd64', 'w10'), +} + + +def calcFileHash(data, hashobj): +hashobj.update(data) + +def calcPEHash(data, hashobj): +# DOS header: magic, ..., PE header offset +mz, pehdr = struct.unpack_from("2s58xI", data, 0) +assert mz == b'MZ' +# PE header: magic, ..., magic in optional header +pe, pemagic = struct.unpack_from("4s20xH", data, pehdr) +assert pe == b'PE\0\0' +# security directory entry in optional header +secdir = pehdr + { +0x10b: 152,# PE32 +0x20b: 168 # PE32+ +}[pemagic] +sec, seclen = struct.unpack_from("2I", data, secdir) +# signature is always the tail part +assert sec + seclen == len(data) + +hashobj.update(data[:pehdr + 88]) # skip checksum +hashobj.update(data[pehdr + 92:secdir]) # skip security directory entry +hashobj.update(data[secdir + 8:sec])# skip signature + +def vrfySig(fname, kind, algo, digest): +meth = { +'spcLink': calcFileHash, +'spcPEImageData': calcPEHash +}[kind] + +fd = os.open(fname, os.O_RDONLY) +m = mmap.mmap(fd, 0, access = mmap.ACCESS_READ) +os.close(fd) + +h = hashlib.new(algo) +meth(m, h) +m.close() +assert h.digest() == digest + +# locate file case-insensitively +def casedFname(dname, fname): +fns = [f for f in os.listdir(dname) if f.lower() == fname.lower()] +assert len(fns) == 1 +return fns[0] + +def processCat(dname, catname): +catname = casedFname(dname, catname) + +attributes, members = parseCat(os.path.join(dname, catname)) +oses = attributes['OS'].split(',') + +# validate catalog members just because we can +kernels = set(('2:' + osMap[o][0]) for o in oses) + +for member in members: +fn = casedFname(dname, member['File']) + +assert kernels.issubset(member['OSAttr'].split(',')) + +sig = member.get('signature') +if sig: +vrfySig(os.path.join(dname, fn), +sig['kind'], sig['digestAlgorithm'], sig['digest']) + +return set(os.path.join(osMap[o][1], osMap[o][2]) for o in oses) + +dryrun = True +cpTree = None +cp = None + +def doMkdir(d): +print("mkdir
[virt-tools-list] [PATCH RFC virtio-win-pkg-scripts 0/2] helpers to standardize driver directory layout
As was discussed some time ago on libguestfs ML (http://thread.gmane.org/gmane.comp.emulators.guestfs/8341/focus=8576) there is a need in a tool that would lay out the Windows guest drivers on a filesystem by Windows flavor and architecture in a way that is - easy to consume by both humans and programs - dependable in the long term This patch series brings in the scripts to do this. The scripts are based on the idea that the most actual information about the suitability of a driver for a particular flavor / architecture is contained in the driver's catalog file (in particular, the process of ISV or WHQL siging may affect it). Since the catalog files are DER-encoded ASN.1 structures the first patch introduces a module to extract relevant information from a .cat file using PyASN1 library. The second patch introduces a script that lays out the drivers by arch/flavor. It assumes that - every driver for a particular arch/flavor is contained in a separate directory - the directory contains a single .inf file; the basename of the file is taken as the name of the package - the .cat file for the package is in the same directory and has the same basename as the .inf - all the files contained in that directory are associated with the driver and go together with it no matter if they are listed in .inf or .cat or not. The virtio-win driver packages I could get my hands on all matched the above assumptions. [ There's no integration with the rest of the system yet as I'd like to receive some comments on these two first. ] Roman Kagan (2): add parser for driver catalog files add script to lay out drivers based on their catalog files util/cpdrivers.py | 191 ++ util/parsecat.py | 166 +++ 2 files changed, 357 insertions(+) create mode 100644 util/cpdrivers.py create mode 100644 util/parsecat.py -- 2.5.0 ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [PATCH RFC virtio-win-pkg-scripts 1/2] add parser for driver catalog files
This script parses ASN.1 structure of the Windows driver catalog files, and extracts information about what architecture and windows flavor the driver is suitable for. Signed-off-by: Roman Kagan --- util/parsecat.py | 166 +++ 1 file changed, 166 insertions(+) create mode 100644 util/parsecat.py diff --git a/util/parsecat.py b/util/parsecat.py new file mode 100644 index 000..02ab45c --- /dev/null +++ b/util/parsecat.py @@ -0,0 +1,166 @@ +#!/usr/bin/python +# +# Copyright 2016 Parallels IP Holdings GmbH +# +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. +""" +Parse relevant items in the ASN.1 structure of a Windows driver catalog file +""" + +import sys, pprint +from pyasn1_modules import rfc2315 +from pyasn1.type import tag, namedtype, namedval, univ, char, useful +from pyasn1.codec.der import decoder + +class CatalogList(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('oid', univ.ObjectIdentifier()) +) + +class CatalogListMemberId(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('oid', univ.ObjectIdentifier()), +namedtype.NamedType('null', univ.Null()) +) + +class CatalogNameValue(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('name', char.BMPString()), +namedtype.NamedType('someInt', univ.Integer()), +namedtype.NamedType('value', univ.OctetString(encoding = 'utf-16-le')) +) + +class SpcKind(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('oid', univ.ObjectIdentifier()), +namedtype.NamedType('someTh', univ.Any()) +) + +class SpcIndirectData(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('spcKind', SpcKind()), +namedtype.NamedType('digest', rfc2315.DigestInfo()) +) + +class MemberAttributeContent(univ.SetOf): +componentType = univ.Any() + +class MemberAttribute(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('oid', univ.ObjectIdentifier()), +namedtype.NamedType('content', MemberAttributeContent()) +) + +class MemberAttributes(univ.SetOf): +componentType = MemberAttribute() + +class CatalogListMember(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('referenceTag', univ.OctetString()), +namedtype.NamedType('attributes', MemberAttributes()) +) + +class CatalogMembers(univ.SequenceOf): +componentType = CatalogListMember() + +class CatalogAttribute(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('oid', univ.ObjectIdentifier()), +namedtype.NamedType('content', univ.OctetString()) +) + +class CatalogAttributes(univ.SequenceOf): +componentType = CatalogAttribute() +tagSet = univ.SequenceOf.tagSet.tagExplicitly(tag.Tag(tag.tagClassContext, +tag.tagFormatConstructed, 0)) + + +class CertTrustList(univ.Sequence): +componentType = namedtype.NamedTypes( +namedtype.NamedType('catalogList', CatalogList()), +namedtype.NamedType('someStr0', univ.OctetString()), +namedtype.NamedType('utcTime', useful.UTCTime()), +namedtype.NamedType('catalogListMemberId', CatalogListMemberId()), +namedtype.NamedType('members', CatalogMembers()), +namedtype.OptionalNamedType('attributes', CatalogAttributes()) +) + +def parseNameValue(attr): +nv, _ = decoder.decode(attr, asn1Spec = CatalogNameValue()) +strtype = type(u'')# python2/3 compat +name, value = str(strtype(nv['name'])), str(strtype(nv['value'])) +assert value[-1] == '\x00' +return name, value[:-1] + +spcKindMap = { +univ.ObjectIdentifier('1.3.6.1.4.1.311.2.1.15'): 'spcPEImageData', +univ.ObjectIdentifier('1.3.6.1.4.1.311.2.1.25'): 'spcLink', +} + +digestAlgoMap = { +univ.ObjectIdentifier('1.3.14.3.2.26'): 'sha1', +univ.ObjectIdentifier('2.16.840.1.101.3.4.2.1'): 'sha256', +} + +def parseSpcIndirectData(attr): +sid, _ = decoder.decode(attr, asn1Spec = SpcIndirectData()) +spcKind, digest = sid['spcKind'], sid['digest'] +algo = digestAlgoMap[digest['digestAlgorithm']['algorithm']] +return 'signature', { +'kind': spcKindMap[spcKind['oid']], +'digestAlgorithm': algo, +'digest': digest['digest'].asOctets() +} + +memberAttrMap = { +univ.ObjectIdentifier('1.3.6.1.4.1.311.12.2.1'): parseNameValue, +univ.ObjectIdentifier('1.3.6.1.4.1.311.12.2.2'): None, +univ.ObjectIdentifier('1.3.6.1.4.1.311.12.2.3'): None, +univ.ObjectIdentifier('1.3.6.1.4
Re: [virt-tools-list] [PATCH RFC virtio-win-pkg-scripts 0/2] helpers to standardize driver directory layout
On Mon, Jan 18, 2016 at 05:15:19PM +0300, Roman Kagan wrote: > As was discussed some time ago on libguestfs ML > (http://thread.gmane.org/gmane.comp.emulators.guestfs/8341/focus=8576) > there is a need in a tool that would lay out the Windows guest drivers > on a filesystem by Windows flavor and architecture in a way that is > > - easy to consume by both humans and programs > - dependable in the long term > > This patch series brings in the scripts to do this. > > The scripts are based on the idea that the most actual information about > the suitability of a driver for a particular flavor / architecture is > contained in the driver's catalog file (in particular, the process of > ISV or WHQL siging may affect it). > > Since the catalog files are DER-encoded ASN.1 structures the first patch > introduces a module to extract relevant information from a .cat file > using PyASN1 library. > > The second patch introduces a script that lays out the drivers by > arch/flavor. > It assumes that > > - every driver for a particular arch/flavor is contained in a separate > directory > > - the directory contains a single .inf file; the basename of the file is > taken as the name of the package > > - the .cat file for the package is in the same directory and has the > same basename as the .inf > > - all the files contained in that directory are associated with the > driver and go together with it no matter if they are listed in .inf or > .cat or not. > > The virtio-win driver packages I could get my hands on all matched the > above assumptions. The approach of reading the .cat file seems reasonable, and IIUC it would let us get rid of the massive DRIVER_OS_MAP table. > [ There's no integration with the rest of the system yet as I'd like to > receive some comments on these two first. ] Right - obviously needs to be integrated into ./make-driver-dir.py which appears to be the "controlling script". Rich. > Roman Kagan (2): > add parser for driver catalog files > add script to lay out drivers based on their catalog files > > util/cpdrivers.py | 191 > ++ > util/parsecat.py | 166 +++ > 2 files changed, 357 insertions(+) > create mode 100644 util/cpdrivers.py > create mode 100644 util/parsecat.py > > -- > 2.5.0 -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] passing metadata to virt-manager or vmm
Just wondering if it is possible to pass metadata to the virt-manager (GUI client) instead of using the virsh command. Thanks, Abdillahi ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list