ia64/xen-unstable

changeset 17969:6c2fe520e32d

Cleanups to suspend-event-channel patches.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Jul 04 12:39:18 2008 +0100 (2008-07-04)
parents 9353f9931d96
children d133d452cb71
files tools/libxc/xc_domain.c tools/libxc/xenctrl.h tools/xcutils/xc_save.c xen/common/domain.c xen/common/event_channel.c xen/include/xen/event.h
line diff
     1.1 --- a/tools/libxc/xc_domain.c	Fri Jul 04 12:20:19 2008 +0100
     1.2 +++ b/tools/libxc/xc_domain.c	Fri Jul 04 12:39:18 2008 +0100
     1.3 @@ -981,7 +981,8 @@ int xc_domain_set_target(
     1.4      return do_domctl(xc_handle, &domctl);
     1.5  }
     1.6  
     1.7 -int xc_dom_subscribe(int xc_handle, domid_t dom, evtchn_port_t port)
     1.8 +int xc_domain_subscribe_for_suspend(
     1.9 +    int xc_handle, domid_t dom, evtchn_port_t port)
    1.10  {
    1.11      DECLARE_DOMCTL;
    1.12  
     2.1 --- a/tools/libxc/xenctrl.h	Fri Jul 04 12:20:19 2008 +0100
     2.2 +++ b/tools/libxc/xenctrl.h	Fri Jul 04 12:39:18 2008 +0100
     2.3 @@ -814,7 +814,8 @@ int xc_flask_op(int xc_handle, flask_op_
     2.4   * Subscribe to state changes in a domain via evtchn.
     2.5   * Returns -1 on failure, in which case errno will be set appropriately.
     2.6   */
     2.7 -int xc_dom_subscribe(int xc_handle, domid_t domid, evtchn_port_t port);
     2.8 +int xc_domain_subscribe_for_suspend(
     2.9 +    int xc_handle, domid_t domid, evtchn_port_t port);
    2.10  
    2.11  /**************************
    2.12   * GRANT TABLE OPERATIONS *
     3.1 --- a/tools/xcutils/xc_save.c	Fri Jul 04 12:20:19 2008 +0100
     3.2 +++ b/tools/xcutils/xc_save.c	Fri Jul 04 12:39:18 2008 +0100
     3.3 @@ -25,9 +25,7 @@
     3.4  
     3.5  static struct suspendinfo {
     3.6      int xce; /* event channel handle */
     3.7 -
     3.8      int suspend_evtchn;
     3.9 -    int suspended_evtchn;
    3.10  } si;
    3.11  
    3.12  /**
    3.13 @@ -47,11 +45,6 @@ static int compat_suspend(int domid)
    3.14  
    3.15  static int suspend_evtchn_release(int xc, int domid)
    3.16  {
    3.17 -    if (si.suspended_evtchn >= 0) {
    3.18 -	xc_dom_subscribe(xc, domid, 0);
    3.19 -	xc_evtchn_unbind(si.xce, si.suspended_evtchn);
    3.20 -	si.suspended_evtchn = -1;
    3.21 -    }
    3.22      if (si.suspend_evtchn >= 0) {
    3.23  	xc_evtchn_unbind(si.xce, si.suspend_evtchn);
    3.24  	si.suspend_evtchn = -1;
    3.25 @@ -75,7 +68,6 @@ static int suspend_evtchn_init(int xc, i
    3.26  
    3.27      si.xce = -1;
    3.28      si.suspend_evtchn = -1;
    3.29 -    si.suspended_evtchn = -1;
    3.30  
    3.31      xs = xs_daemon_open();
    3.32      if (!xs) {
    3.33 @@ -107,14 +99,7 @@ static int suspend_evtchn_init(int xc, i
    3.34  	goto cleanup;
    3.35      }
    3.36  
    3.37 -    si.suspended_evtchn = xc_evtchn_bind_unbound_port(si.xce, domid);
    3.38 -    if (si.suspended_evtchn < 0) {
    3.39 -	errx(1, "failed to allocate suspend notification port: %d",
    3.40 -	     si.suspended_evtchn);
    3.41 -	goto cleanup;
    3.42 -    }
    3.43 -
    3.44 -    rc = xc_dom_subscribe(xc, domid, si.suspended_evtchn);
    3.45 +    rc = xc_domain_subscribe_for_suspend(xc, domid, port);
    3.46      if (rc < 0) {
    3.47  	errx(1, "failed to subscribe to domain: %d", rc);
    3.48  	goto cleanup;
    3.49 @@ -149,10 +134,10 @@ static int evtchn_suspend(int domid)
    3.50  	errx(1, "error polling suspend notification channel: %d", rc);
    3.51  	return 0;
    3.52        }
    3.53 -    } while (rc != si.suspended_evtchn);
    3.54 +    } while (rc != si.suspend_evtchn);
    3.55  
    3.56      /* harmless for one-off suspend */
    3.57 -    if (xc_evtchn_unmask(si.xce, si.suspended_evtchn) < 0)
    3.58 +    if (xc_evtchn_unmask(si.xce, si.suspend_evtchn) < 0)
    3.59  	errx(1, "failed to unmask suspend notification channel: %d", rc);
    3.60  
    3.61      /* notify xend that it can do device migration */
     4.1 --- a/xen/common/domain.c	Fri Jul 04 12:20:19 2008 +0100
     4.2 +++ b/xen/common/domain.c	Fri Jul 04 12:39:18 2008 +0100
     4.3 @@ -98,7 +98,7 @@ static void __domain_finalise_shutdown(s
     4.4  
     4.5      d->is_shut_down = 1;
     4.6      if ( (d->shutdown_code == SHUTDOWN_suspend) && d->suspend_evtchn )
     4.7 -        evtchn_set_pending(dom0->vcpu[0], d->suspend_evtchn);
     4.8 +        evtchn_send(d, d->suspend_evtchn);
     4.9      else
    4.10          send_guest_global_virq(dom0, VIRQ_DOM_EXC);
    4.11  }
     5.1 --- a/xen/common/event_channel.c	Fri Jul 04 12:20:19 2008 +0100
     5.2 +++ b/xen/common/event_channel.c	Fri Jul 04 12:39:18 2008 +0100
     5.3 @@ -56,6 +56,8 @@
     5.4          goto out;                                                   \
     5.5      } while ( 0 )
     5.6  
     5.7 +static int evtchn_set_pending(struct vcpu *v, int port);
     5.8 +
     5.9  static int virq_is_global(int virq)
    5.10  {
    5.11      int rc;
    5.12 @@ -470,11 +472,10 @@ static long evtchn_close(evtchn_close_t 
    5.13      return __evtchn_close(current->domain, close->port);
    5.14  }
    5.15  
    5.16 -
    5.17 -long evtchn_send(unsigned int lport)
    5.18 +int evtchn_send(struct domain *d, unsigned int lport)
    5.19  {
    5.20      struct evtchn *lchn, *rchn;
    5.21 -    struct domain *ld = current->domain, *rd;
    5.22 +    struct domain *ld = d, *rd;
    5.23      struct vcpu   *rvcpu;
    5.24      int            rport, ret = 0;
    5.25  
    5.26 @@ -534,8 +535,7 @@ out:
    5.27      return ret;
    5.28  }
    5.29  
    5.30 -
    5.31 -int evtchn_set_pending(struct vcpu *v, int port)
    5.32 +static int evtchn_set_pending(struct vcpu *v, int port)
    5.33  {
    5.34      struct domain *d = v->domain;
    5.35  
    5.36 @@ -891,7 +891,7 @@ long do_event_channel_op(int cmd, XEN_GU
    5.37          struct evtchn_send send;
    5.38          if ( copy_from_guest(&send, arg, 1) != 0 )
    5.39              return -EFAULT;
    5.40 -        rc = evtchn_send(send.port);
    5.41 +        rc = evtchn_send(current->domain, send.port);
    5.42          break;
    5.43      }
    5.44  
     6.1 --- a/xen/include/xen/event.h	Fri Jul 04 12:20:19 2008 +0100
     6.2 +++ b/xen/include/xen/event.h	Fri Jul 04 12:39:18 2008 +0100
     6.3 @@ -16,9 +16,6 @@
     6.4  #include <asm/bitops.h>
     6.5  #include <asm/event.h>
     6.6  
     6.7 -/* Returns TRUE if the delivery port was already pending. */
     6.8 -int evtchn_set_pending(struct vcpu *v, int port);
     6.9 -
    6.10  /*
    6.11   * send_guest_vcpu_virq: Notify guest via a per-VCPU VIRQ.
    6.12   *  @v:        VCPU to which virtual IRQ should be sent
    6.13 @@ -41,8 +38,8 @@ void send_guest_global_virq(struct domai
    6.14   */
    6.15  int send_guest_pirq(struct domain *d, int pirq);
    6.16  
    6.17 -/* Send a notification from a local event-channel port. */
    6.18 -long evtchn_send(unsigned int lport);
    6.19 +/* Send a notification from a given domain's event-channel port. */
    6.20 +int evtchn_send(struct domain *d, unsigned int lport);
    6.21  
    6.22  /* Bind a local event-channel port to the specified VCPU. */
    6.23  long evtchn_bind_vcpu(unsigned int port, unsigned int vcpu_id);