All of lore.kernel.org
 help / color / mirror / Atom feed
From: Prasanna Kumar Kalever <pkalever@redhat.com>
To: Peter Krempa <pkrempa@redhat.com>
Cc: kwolf@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org,
	deepakcs@redhat.com, bharata@linux.vnet.ibm.com,
	rtalur@redhat.com
Subject: Re: [Qemu-devel] [PATCH 3/3] block/gluster: add support for multiple gluster servers
Date: Mon, 9 Nov 2015 04:40:09 -0500 (EST)	[thread overview]
Message-ID: <2024052690.6797703.1447062009061.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20151109070445.GF3391301@andariel.pipo.sk>

On Monday, November 9, 2015 12:34:45 PM, Peter Krempa wrote:
> On Thu, Nov 05, 2015 at 07:45:50 -0500, Prasanna Kumar Kalever wrote:
> > On Thursday, November 5, 2015 6:07:06 PM, Prasanna Kumar Kalever wrote:
> > > This patch adds a way to specify multiple volfile servers to the gluster
> > > block backend of QEMU with tcp|rdma transport types and their port
> > > numbers.
> > > 
> > > Problem:
> > > 
> > > Currently VM Image on gluster volume is specified like this:
> > 
> 
> [...]
> 
> > > @@ -345,7 +676,7 @@ static int qemu_gluster_open(BlockDriverState *bs,
> > > QDict
> > > *options,
> > >  
> > >  out:
> > >      qemu_opts_del(opts);
> > > -    qemu_gluster_gconf_free(gconf);
> > > +    qapi_free_BlockdevOptionsGluster(gconf);
> > 
> > Can some one help me please ?
> > This leads to crash in the second iteration i.e. while freeing
> > "gconf->servers->next->value"
> 
> So, prior to this you allocate a array of the data structures as:
> 
> +    gsconf = g_new0(GlusterServer, num_servers);
> +
> +    ptr = qemu_opt_get(opts, GLUSTER_OPT_VOLUME);
> +    if (!ptr) {
> +        error_setg(&local_err, "Error: qemu_gluster: please provide 'volume'
> "
> +                               "option");
> +        goto out;
> +    }
> 
> Then you use the following code to fill the linked list:
> 
> +      if (gconf->servers == NULL) {
> +            gconf->servers = g_new0(GlusterServerList, 1);
> +            gconf->servers->value = &gsconf[i];
> 
> So here you set the value. For a i of 0 the '&gsconf[i]' expression will
> be a pointer with equal address to 'gsconf'. For explanation:
> 
> 'gsconf[i]' can be written as '*(gsconf + i)', so
> '&gsconf[i]' becomes basically '&(*(gsconf + i))'
> 
> This can be also simplified to:
> 'gsconf + i'. For a i of 0 this becomes the same pointer as 'gsconf'
> 
> And once you use that with free(), the whole gsconf array will be freed.
> All the other pointers that you've filled to the linked list become
> invalid, since they were pointing into the same array that was
> completely freed in the first iteration.

Thanks for the help Peter, It solves the problem.

-Prasanna 
> 
> Peter
> 

  reply	other threads:[~2015-11-09  9:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-05 12:37 [Qemu-devel] [PATCH RFC 0/3] block/gluster: add support for multiple gluster servers Prasanna Kumar Kalever
2015-11-05 12:37 ` [Qemu-devel] [PATCH 3/3] " Prasanna Kumar Kalever
2015-11-05 12:45   ` Prasanna Kumar Kalever
2015-11-09  7:04     ` Peter Krempa
2015-11-09  9:40       ` Prasanna Kumar Kalever [this message]
2015-11-09 21:11         ` Eric Blake

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=2024052690.6797703.1447062009061.JavaMail.zimbra@redhat.com \
    --to=pkalever@redhat.com \
    --cc=bharata@linux.vnet.ibm.com \
    --cc=deepakcs@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=rtalur@redhat.com \
    --cc=stefanha@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.