All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it
@ 2018-02-08 23:14 Marek Marczykowski-Górecki
  2018-02-09 11:35 ` Roger Pau Monné
  2018-02-23 18:47 ` Wei Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Marek Marczykowski-Górecki @ 2018-02-08 23:14 UTC (permalink / raw)
  To: xen-devel
  Cc: Wei Liu, Ian Jackson, Marek Marczykowski-Górecki,
	Marcus of Wetware Labs

When fd=-1, no savefile will be written, but the domain will still be
suspended (but not destroyed). The main reason for this functionality is
to suspend the host while some domains are running, potentially holding
PCI devices. This will give a chance to a driver in such a domain to
properly suspend device.

It would be better to have separate function for this, but in fact it
should be named libxl_domain_suspend, then the current one renamed to
libxl_domain_save. Since that would break API compatibility, keep it in
the same function.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Marcus of Wetware Labs <marcus@wetwa.re>
---
 tools/libxl/libxl_domain.c | 53 +++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 15 deletions(-)

diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 13b1c73d40..c95eaa30ca 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -486,6 +486,13 @@ static void domain_suspend_cb(libxl__egc *egc,
 
 }
 
+static void domain_suspend_empty_cb(libxl__egc *egc,
+                              libxl__domain_suspend_state *dss, int rc)
+{
+    STATE_AO_GC(dss->ao);
+    libxl__ao_complete(egc,ao,rc);
+}
+
 int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
                          const libxl_asyncop_how *ao_how)
 {
@@ -498,25 +505,41 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
         goto out_err;
     }
 
-    libxl__domain_save_state *dss;
-    GCNEW(dss);
+    if (fd >= 0) {
+        libxl__domain_save_state *dss;
+        GCNEW(dss);
 
-    dss->ao = ao;
-    dss->callback = domain_suspend_cb;
+        dss->ao = ao;
+        dss->callback = domain_suspend_cb;
 
-    dss->domid = domid;
-    dss->fd = fd;
-    dss->type = type;
-    dss->live = flags & LIBXL_SUSPEND_LIVE;
-    dss->debug = flags & LIBXL_SUSPEND_DEBUG;
-    dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE;
+        dss->domid = domid;
+        dss->fd = fd;
+        dss->type = type;
+        dss->live = flags & LIBXL_SUSPEND_LIVE;
+        dss->debug = flags & LIBXL_SUSPEND_DEBUG;
+        dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE;
 
-    rc = libxl__fd_flags_modify_save(gc, dss->fd,
-                                     ~(O_NONBLOCK|O_NDELAY), 0,
-                                     &dss->fdfl);
-    if (rc < 0) goto out_err;
+        rc = libxl__fd_flags_modify_save(gc, dss->fd,
+                                         ~(O_NONBLOCK|O_NDELAY), 0,
+                                         &dss->fdfl);
+        if (rc < 0) goto out_err;
+
+        libxl__domain_save(egc, dss);
+    } else {
+        libxl__domain_suspend_state *dsps;
+        GCNEW(dsps);
+        dsps->ao = ao;
+        dsps->domid = domid;
+        dsps->type = type;
+        dsps->guest_evtchn.port = -1;
+        dsps->guest_evtchn_lockfd = -1;
+        dsps->guest_responded = 0;
+        rc = libxl__domain_suspend_init(egc, dsps, type);
+        if (rc < 0) goto out_err;
+        dsps->callback_common_done = domain_suspend_empty_cb;
+        libxl__domain_suspend(egc, dsps);
+    }
 
-    libxl__domain_save(egc, dss);
     return AO_INPROGRESS;
 
  out_err:
-- 
2.13.6


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it
  2018-02-08 23:14 [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it Marek Marczykowski-Górecki
@ 2018-02-09 11:35 ` Roger Pau Monné
  2018-02-23 18:47 ` Wei Liu
  1 sibling, 0 replies; 5+ messages in thread
From: Roger Pau Monné @ 2018-02-09 11:35 UTC (permalink / raw)
  To: Marek Marczykowski-Górecki
  Cc: Ian Jackson, Marcus of Wetware Labs, Wei Liu, xen-devel

On Fri, Feb 09, 2018 at 12:14:03AM +0100, Marek Marczykowski-Górecki wrote:
> When fd=-1, no savefile will be written, but the domain will still be
> suspended (but not destroyed). The main reason for this functionality is
> to suspend the host while some domains are running, potentially holding
> PCI devices. This will give a chance to a driver in such a domain to
> properly suspend device.
> 
> It would be better to have separate function for this, but in fact it
> should be named libxl_domain_suspend, then the current one renamed to
> libxl_domain_save. Since that would break API compatibility, keep it in
> the same function.
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Signed-off-by: Marcus of Wetware Labs <marcus@wetwa.re>
> ---
>  tools/libxl/libxl_domain.c | 53 +++++++++++++++++++++++++++++++++-------------
>  1 file changed, 38 insertions(+), 15 deletions(-)
> 
> diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
> index 13b1c73d40..c95eaa30ca 100644
> --- a/tools/libxl/libxl_domain.c
> +++ b/tools/libxl/libxl_domain.c
> @@ -486,6 +486,13 @@ static void domain_suspend_cb(libxl__egc *egc,
>  
>  }
>  
> +static void domain_suspend_empty_cb(libxl__egc *egc,
> +                              libxl__domain_suspend_state *dss, int rc)
> +{
> +    STATE_AO_GC(dss->ao);
> +    libxl__ao_complete(egc,ao,rc);
> +}
> +
>  int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
>                           const libxl_asyncop_how *ao_how)
>  {
> @@ -498,25 +505,41 @@ int libxl_domain_suspend(libxl_ctx *ctx, uint32_t domid, int fd, int flags,
>          goto out_err;
>      }
>  
> -    libxl__domain_save_state *dss;
> -    GCNEW(dss);
> +    if (fd >= 0) {
> +        libxl__domain_save_state *dss;

Newline.

> +        GCNEW(dss);
>  
> -    dss->ao = ao;
> -    dss->callback = domain_suspend_cb;
> +        dss->ao = ao;
> +        dss->callback = domain_suspend_cb;
>  
> -    dss->domid = domid;
> -    dss->fd = fd;
> -    dss->type = type;
> -    dss->live = flags & LIBXL_SUSPEND_LIVE;
> -    dss->debug = flags & LIBXL_SUSPEND_DEBUG;
> -    dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE;
> +        dss->domid = domid;
> +        dss->fd = fd;
> +        dss->type = type;
> +        dss->live = flags & LIBXL_SUSPEND_LIVE;
> +        dss->debug = flags & LIBXL_SUSPEND_DEBUG;
> +        dss->checkpointed_stream = LIBXL_CHECKPOINTED_STREAM_NONE;
>  
> -    rc = libxl__fd_flags_modify_save(gc, dss->fd,
> -                                     ~(O_NONBLOCK|O_NDELAY), 0,
> -                                     &dss->fdfl);
> -    if (rc < 0) goto out_err;
> +        rc = libxl__fd_flags_modify_save(gc, dss->fd,
> +                                         ~(O_NONBLOCK|O_NDELAY), 0,
> +                                         &dss->fdfl);
> +        if (rc < 0) goto out_err;
> +
> +        libxl__domain_save(egc, dss);
> +    } else {
> +        libxl__domain_suspend_state *dsps;

Newline.

> +        GCNEW(dsps);
> +        dsps->ao = ao;
> +        dsps->domid = domid;
> +        dsps->type = type;
> +        dsps->guest_evtchn.port = -1;
> +        dsps->guest_evtchn_lockfd = -1;
> +        dsps->guest_responded = 0;
> +        rc = libxl__domain_suspend_init(egc, dsps, type);

If you call libxl__domain_suspend_init just after allocating the
struct you can avoid setting type, port, guest_evtchn_lockfd and
guest_responded.

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it
  2018-02-08 23:14 [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it Marek Marczykowski-Górecki
  2018-02-09 11:35 ` Roger Pau Monné
@ 2018-02-23 18:47 ` Wei Liu
  2018-02-23 20:03   ` Marek Marczykowski-Górecki
  1 sibling, 1 reply; 5+ messages in thread
From: Wei Liu @ 2018-02-23 18:47 UTC (permalink / raw)
  To: Marek Marczykowski-Górecki
  Cc: Wei Liu, Marcus of Wetware Labs, Ian Jackson, xen-devel

On Fri, Feb 09, 2018 at 12:14:03AM +0100, Marek Marczykowski-Górecki wrote:
> When fd=-1, no savefile will be written, but the domain will still be
> suspended (but not destroyed). The main reason for this functionality is
> to suspend the host while some domains are running, potentially holding
> PCI devices. This will give a chance to a driver in such a domain to
> properly suspend device.
> 
> It would be better to have separate function for this, but in fact it
> should be named libxl_domain_suspend, then the current one renamed to
> libxl_domain_save. Since that would break API compatibility, keep it in
> the same function.
> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> Signed-off-by: Marcus of Wetware Labs <marcus@wetwa.re>

The basic idea seems sensible.

Please add a comment to libxl.h to specify the new semantics.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it
  2018-02-23 18:47 ` Wei Liu
@ 2018-02-23 20:03   ` Marek Marczykowski-Górecki
  2018-03-09 16:55     ` Wei Liu
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Marczykowski-Górecki @ 2018-02-23 20:03 UTC (permalink / raw)
  To: Wei Liu; +Cc: Marcus of Wetware Labs, Ian Jackson, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1328 bytes --]

On Fri, Feb 23, 2018 at 06:47:57PM +0000, Wei Liu wrote:
> On Fri, Feb 09, 2018 at 12:14:03AM +0100, Marek Marczykowski-Górecki wrote:
> > When fd=-1, no savefile will be written, but the domain will still be
> > suspended (but not destroyed). The main reason for this functionality is
> > to suspend the host while some domains are running, potentially holding
> > PCI devices. This will give a chance to a driver in such a domain to
> > properly suspend device.
> > 
> > It would be better to have separate function for this, but in fact it
> > should be named libxl_domain_suspend, then the current one renamed to
> > libxl_domain_save. Since that would break API compatibility, keep it in
> > the same function.
> > 
> > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > Signed-off-by: Marcus of Wetware Labs <marcus@wetwa.re>
> 
> The basic idea seems sensible.
> 
> Please add a comment to libxl.h to specify the new semantics.

Hmm, while I'm looking at it, maybe better idea would be to use flags
for that? I'd call it LIBXL_SUSPEND_SUSPEND, but it looks stupid, any
better idea?

-- 
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it
  2018-02-23 20:03   ` Marek Marczykowski-Górecki
@ 2018-03-09 16:55     ` Wei Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2018-03-09 16:55 UTC (permalink / raw)
  To: Marek Marczykowski-Górecki
  Cc: Ian Jackson, Marcus of Wetware Labs, Wei Liu, xen-devel

On Fri, Feb 23, 2018 at 09:03:26PM +0100, Marek Marczykowski-Górecki wrote:
> On Fri, Feb 23, 2018 at 06:47:57PM +0000, Wei Liu wrote:
> > On Fri, Feb 09, 2018 at 12:14:03AM +0100, Marek Marczykowski-Górecki wrote:
> > > When fd=-1, no savefile will be written, but the domain will still be
> > > suspended (but not destroyed). The main reason for this functionality is
> > > to suspend the host while some domains are running, potentially holding
> > > PCI devices. This will give a chance to a driver in such a domain to
> > > properly suspend device.
> > > 
> > > It would be better to have separate function for this, but in fact it
> > > should be named libxl_domain_suspend, then the current one renamed to
> > > libxl_domain_save. Since that would break API compatibility, keep it in
> > > the same function.
> > > 
> > > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > > Signed-off-by: Marcus of Wetware Labs <marcus@wetwa.re>
> > 
> > The basic idea seems sensible.
> > 
> > Please add a comment to libxl.h to specify the new semantics.
> 
> Hmm, while I'm looking at it, maybe better idea would be to use flags
> for that? I'd call it LIBXL_SUSPEND_SUSPEND, but it looks stupid, any
> better idea?

I don't have any better idea I'm afraid...

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-09 16:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-08 23:14 [PATCH] libxl: allow libxl_domain_suspend to simply suspend a domain, without saving it Marek Marczykowski-Górecki
2018-02-09 11:35 ` Roger Pau Monné
2018-02-23 18:47 ` Wei Liu
2018-02-23 20:03   ` Marek Marczykowski-Górecki
2018-03-09 16:55     ` Wei Liu

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.