From: George Dunlap <george.dunlap@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Nick Rosbrook <rosbrookn@ainfosec.com>
Subject: Re: [Xen-devel] [PATCH 1/9] golang/xenlight: Don't try to marshall zero-length arrays
Date: Fri, 27 Dec 2019 16:36:10 +0000 [thread overview]
Message-ID: <796db074-f476-2768-6009-573b62a6e406@citrix.com> (raw)
In-Reply-To: <20191227163224.4113837-1-george.dunlap@citrix.com>
[-- Attachment #1: Type: text/plain, Size: 824 bytes --]
On 12/27/19 4:32 PM, George Dunlap wrote:
> The current fromC array code will do the "magic" casting and
> martialling even when num_foo variable is 0. Go crashes when doing
> the cast.
>
> Furthermore, the current toC array code will convert a nil slice into
> a zero-length malloc. The resulting pointer is non-NULL, and confuses
> libxl.
>
> Only do array marshalling if the number of elements is non-zero;
> otherwise, leave the target pointer empty (nil for Go slices, NULL for
> C arrays).
>
> The toC half of this should be folded into "golang/xenlight:
> implement array Go to C marshaling".
>
> Signed-off-by: George Dunlap <george.dunlap@citrix.com>
The .go program I used to test this series is attached, to give you an
idea what the current iteration looks like, and potentially give it a spin.
-George
[-- Attachment #2: xltest.go --]
[-- Type: text/x-go, Size: 1687 bytes --]
package main
import (
"fmt"
xl "golang.xenproject.org/xenlight"
)
func main() {
ctx, err := xl.NewContext()
if err != nil {
fmt.Printf("Opening context: %v\n", err)
return
}
defer ctx.Close()
doms := ctx.ListDomain()
for i := range doms {
fmt.Printf("%d %v\n", doms[i].Domid, doms[i].Uuid)
}
fmt.Printf("String for error ErrorNonspecific: %v\n", xl.ErrorNonspecific)
// type = "pv"
dconf, err := xl.NewDomainConfig(xl.DomainTypePv)
if err != nil {
fmt.Printf("NewDomainConfig: %v\n", err)
return
}
dconf.CInfo.Type = xl.DomainTypePv
// name = "c6-01"
dconf.CInfo.Name = "c6-01"
// vcpus=4
dconf.BInfo.MaxVcpus = 4
// memory = "2048"
dconf.BInfo.MaxMemkb = 2048 * 1024
dconf.BInfo.TargetMemkb = 2048 * 1024
// on_crash = 'destroy'
dconf.OnCrash = xl.ActionOnShutdownDestroy
// bootloader = "pygrub"
dconf.BInfo.Bootloader = "pygrub"
// disk = [ 'vdev=hda,format=raw,target=/images/c6-01.raw']
{
disk, err := xl.NewDeviceDisk()
if err != nil {
fmt.Printf("NewDeviceDisk: %v\n", err)
return
}
disk.Vdev = "hda"
//disk.DiskBackend = xl.DiskBackendPhy
disk.Format = xl.DiskFormatRaw
disk.PdevPath = "/images/c6-01.raw"
dconf.Disks = append(dconf.Disks, *disk)
}
// vif = [ 'mac=5a:5b:d6:f1:d6:b4' ]
{
vif, err := xl.NewDeviceNic()
if err != nil {
fmt.Printf("NewDeviceNic: %v\n", err)
return
}
vif.Mac = xl.Mac{ 0x5a, 0x5b, 0xd6, 0x31, 0xd6, 0xb4 }
dconf.Nics = append(dconf.Nics, *vif)
}
// serial='pty' # HVM only
did, err := ctx.DomainCreateNew(dconf)
if err != nil {
fmt.Printf("Creating domain: %v\n", err)
return
}
fmt.Printf("Domain %s(%d) created successfully", dconf.CInfo.Name, did)
}
[-- Attachment #3: Type: text/plain, Size: 157 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-12-27 16:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-27 16:32 [Xen-devel] [PATCH 1/9] golang/xenlight: Don't try to marshall zero-length arrays George Dunlap
2019-12-27 16:32 ` [Xen-devel] [PATCH 2/9] golang/xenlight: Do proper nil / NULL conversions for builtin Bitmap type George Dunlap
2020-01-04 18:00 ` Nick Rosbrook
2019-12-27 16:32 ` [Xen-devel] [PATCH 3/9] golang/xenlight: Convert "" to NULL George Dunlap
2020-01-04 18:25 ` Nick Rosbrook
2019-12-27 16:32 ` [Xen-devel] [PATCH 4/9] go/xenlight: Fix CpuidPoliclyList conversion George Dunlap
2020-01-04 18:42 ` Nick Rosbrook
2019-12-27 16:32 ` [Xen-devel] [PATCH 5/9] go/xenlight: More informative error messages George Dunlap
2020-01-04 19:06 ` Nick Rosbrook
2020-01-16 16:46 ` George Dunlap
2019-12-27 16:32 ` [Xen-devel] [PATCH 6/9] golang/xenlight: Errors are negative George Dunlap
2020-01-04 19:27 ` Nick Rosbrook
2020-01-16 16:59 ` George Dunlap
2019-12-27 16:32 ` [Xen-devel] [PATCH 7/9] golang/xenlight: Default loglevel to DEBUG until we get everything working George Dunlap
2019-12-27 16:32 ` [Xen-devel] [PATCH 8/9] RFC: golang/xenlight: Notify xenlight of SIGCHLD George Dunlap
2019-12-27 16:32 ` [Xen-devel] [PATCH 9/9] DO NOT APPLY: Sketch constructors, DomainCreateNew George Dunlap
2019-12-27 16:36 ` George Dunlap [this message]
2020-01-04 17:11 ` [Xen-devel] [PATCH 1/9] golang/xenlight: Don't try to marshall zero-length arrays Nick Rosbrook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=796db074-f476-2768-6009-573b62a6e406@citrix.com \
--to=george.dunlap@citrix.com \
--cc=rosbrookn@ainfosec.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).