Browse code

Use State as embedded to Container

Signed-off-by: Alexandr Morozov <lk4d4math@gmail.com>

Alexandr Morozov authored on 2014/09/01 00:20:35
Showing 17 changed files
... ...
@@ -413,7 +413,7 @@ func (b *Builder) run(c *daemon.Container) error {
413 413
 	}
414 414
 
415 415
 	// Wait for it to finish
416
-	if ret, _ := c.State.WaitStop(-1 * time.Second); ret != 0 {
416
+	if ret, _ := c.WaitStop(-1 * time.Second); ret != 0 {
417 417
 		err := &utils.JSONError{
418 418
 			Message: fmt.Sprintf("The command %v returned a non-zero code: %d", b.Config.Cmd, ret),
419 419
 			Code:    ret,
... ...
@@ -106,7 +106,7 @@ func (daemon *Daemon) ContainerAttach(job *engine.Job) engine.Status {
106 106
 		// If we are in stdinonce mode, wait for the process to end
107 107
 		// otherwise, simply return
108 108
 		if container.Config.StdinOnce && !container.Config.Tty {
109
-			container.State.WaitStop(-1 * time.Second)
109
+			container.WaitStop(-1 * time.Second)
110 110
 		}
111 111
 	}
112 112
 	return engine.StatusOK
... ...
@@ -283,7 +283,7 @@ func (container *Container) Start() (err error) {
283 283
 	container.Lock()
284 284
 	defer container.Unlock()
285 285
 
286
-	if container.State.Running {
286
+	if container.Running {
287 287
 		return nil
288 288
 	}
289 289
 
... ...
@@ -333,7 +333,7 @@ func (container *Container) Run() error {
333 333
 	if err := container.Start(); err != nil {
334 334
 		return err
335 335
 	}
336
-	container.State.WaitStop(-1 * time.Second)
336
+	container.WaitStop(-1 * time.Second)
337 337
 	return nil
338 338
 }
339 339
 
... ...
@@ -347,7 +347,7 @@ func (container *Container) Output() (output []byte, err error) {
347 347
 		return nil, err
348 348
 	}
349 349
 	output, err = ioutil.ReadAll(pipe)
350
-	container.State.WaitStop(-1 * time.Second)
350
+	container.WaitStop(-1 * time.Second)
351 351
 	return output, err
352 352
 }
353 353
 
... ...
@@ -533,11 +533,11 @@ func (container *Container) KillSig(sig int) error {
533 533
 	defer container.Unlock()
534 534
 
535 535
 	// We could unpause the container for them rather than returning this error
536
-	if container.State.Paused {
536
+	if container.Paused {
537 537
 		return fmt.Errorf("Container %s is paused. Unpause the container before stopping", container.ID)
538 538
 	}
539 539
 
540
-	if !container.State.Running {
540
+	if !container.Running {
541 541
 		return nil
542 542
 	}
543 543
 
... ...
@@ -548,7 +548,7 @@ func (container *Container) KillSig(sig int) error {
548 548
 	// if the container is currently restarting we do not need to send the signal
549 549
 	// to the process.  Telling the monitor that it should exit on it's next event
550 550
 	// loop is enough
551
-	if container.State.Restarting {
551
+	if container.Restarting {
552 552
 		return nil
553 553
 	}
554 554
 
... ...
@@ -556,27 +556,27 @@ func (container *Container) KillSig(sig int) error {
556 556
 }
557 557
 
558 558
 func (container *Container) Pause() error {
559
-	if container.State.IsPaused() {
559
+	if container.IsPaused() {
560 560
 		return fmt.Errorf("Container %s is already paused", container.ID)
561 561
 	}
562
-	if !container.State.IsRunning() {
562
+	if !container.IsRunning() {
563 563
 		return fmt.Errorf("Container %s is not running", container.ID)
564 564
 	}
565 565
 	return container.daemon.Pause(container)
566 566
 }
567 567
 
568 568
 func (container *Container) Unpause() error {
569
-	if !container.State.IsPaused() {
569
+	if !container.IsPaused() {
570 570
 		return fmt.Errorf("Container %s is not paused", container.ID)
571 571
 	}
572
-	if !container.State.IsRunning() {
572
+	if !container.IsRunning() {
573 573
 		return fmt.Errorf("Container %s is not running", container.ID)
574 574
 	}
575 575
 	return container.daemon.Unpause(container)
576 576
 }
577 577
 
578 578
 func (container *Container) Kill() error {
579
-	if !container.State.IsRunning() {
579
+	if !container.IsRunning() {
580 580
 		return nil
581 581
 	}
582 582
 
... ...
@@ -586,9 +586,9 @@ func (container *Container) Kill() error {
586 586
 	}
587 587
 
588 588
 	// 2. Wait for the process to die, in last resort, try to kill the process directly
589
-	if _, err := container.State.WaitStop(10 * time.Second); err != nil {
589
+	if _, err := container.WaitStop(10 * time.Second); err != nil {
590 590
 		// Ensure that we don't kill ourselves
591
-		if pid := container.State.GetPid(); pid != 0 {
591
+		if pid := container.GetPid(); pid != 0 {
592 592
 			log.Infof("Container %s failed to exit within 10 seconds of kill - trying direct SIGKILL", utils.TruncateID(container.ID))
593 593
 			if err := syscall.Kill(pid, 9); err != nil {
594 594
 				return err
... ...
@@ -596,12 +596,12 @@ func (container *Container) Kill() error {
596 596
 		}
597 597
 	}
598 598
 
599
-	container.State.WaitStop(-1 * time.Second)
599
+	container.WaitStop(-1 * time.Second)
600 600
 	return nil
601 601
 }
602 602
 
603 603
 func (container *Container) Stop(seconds int) error {
604
-	if !container.State.IsRunning() {
604
+	if !container.IsRunning() {
605 605
 		return nil
606 606
 	}
607 607
 
... ...
@@ -614,11 +614,11 @@ func (container *Container) Stop(seconds int) error {
614 614
 	}
615 615
 
616 616
 	// 2. Wait for the process to exit on its own
617
-	if _, err := container.State.WaitStop(time.Duration(seconds) * time.Second); err != nil {
617
+	if _, err := container.WaitStop(time.Duration(seconds) * time.Second); err != nil {
618 618
 		log.Infof("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds)
619 619
 		// 3. If it doesn't, then send SIGKILL
620 620
 		if err := container.Kill(); err != nil {
621
-			container.State.WaitStop(-1 * time.Second)
621
+			container.WaitStop(-1 * time.Second)
622 622
 			return err
623 623
 		}
624 624
 	}
... ...
@@ -1006,7 +1006,7 @@ func (container *Container) setupLinkedContainers() ([]string, error) {
1006 1006
 		}
1007 1007
 
1008 1008
 		for linkAlias, child := range children {
1009
-			if !child.State.IsRunning() {
1009
+			if !child.IsRunning() {
1010 1010
 				return nil, fmt.Errorf("Cannot link to a non running container: %s AS %s", child.Name, linkAlias)
1011 1011
 			}
1012 1012
 
... ...
@@ -1173,7 +1173,7 @@ func (container *Container) getNetworkedContainer() (*Container, error) {
1173 1173
 		if nc == nil {
1174 1174
 			return nil, fmt.Errorf("no such container to join network: %s", parts[1])
1175 1175
 		}
1176
-		if !nc.State.IsRunning() {
1176
+		if !nc.IsRunning() {
1177 1177
 			return nil, fmt.Errorf("cannot join network of a non running container: %s", parts[1])
1178 1178
 		}
1179 1179
 		return nc, nil
... ...
@@ -213,11 +213,11 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
213 213
 	// FIXME: if the container is supposed to be running but is not, auto restart it?
214 214
 	//        if so, then we need to restart monitor and init a new lock
215 215
 	// If the container is supposed to be running, make sure of it
216
-	if container.State.IsRunning() {
216
+	if container.IsRunning() {
217 217
 		log.Debugf("killing old running container %s", container.ID)
218 218
 
219
-		existingPid := container.State.Pid
220
-		container.State.SetStopped(0)
219
+		existingPid := container.Pid
220
+		container.SetStopped(0)
221 221
 
222 222
 		// We only have to handle this for lxc because the other drivers will ensure that
223 223
 		// no processes are left when docker dies
... ...
@@ -249,7 +249,7 @@ func (daemon *Daemon) register(container *Container, updateSuffixarray bool) err
249 249
 
250 250
 			log.Debugf("Marking as stopped")
251 251
 
252
-			container.State.SetStopped(-127)
252
+			container.SetStopped(-127)
253 253
 			if err := container.ToDisk(); err != nil {
254 254
 				return err
255 255
 			}
... ...
@@ -363,7 +363,7 @@ func (daemon *Daemon) restore() error {
363 363
 
364 364
 		for _, container := range registeredContainers {
365 365
 			if container.hostConfig.RestartPolicy.Name == "always" ||
366
-				(container.hostConfig.RestartPolicy.Name == "on-failure" && container.State.ExitCode != 0) {
366
+				(container.hostConfig.RestartPolicy.Name == "on-failure" && container.ExitCode != 0) {
367 367
 				log.Debugf("Starting container %s", container.ID)
368 368
 
369 369
 				if err := container.Start(); err != nil {
... ...
@@ -891,7 +891,7 @@ func (daemon *Daemon) shutdown() error {
891 891
 	log.Debugf("starting clean shutdown of all containers...")
892 892
 	for _, container := range daemon.List() {
893 893
 		c := container
894
-		if c.State.IsRunning() {
894
+		if c.IsRunning() {
895 895
 			log.Debugf("stopping %s", c.ID)
896 896
 			group.Add(1)
897 897
 
... ...
@@ -900,7 +900,7 @@ func (daemon *Daemon) shutdown() error {
900 900
 				if err := c.KillSig(15); err != nil {
901 901
 					log.Debugf("kill 15 error for %s - %s", c.ID, err)
902 902
 				}
903
-				c.State.WaitStop(-1 * time.Second)
903
+				c.WaitStop(-1 * time.Second)
904 904
 				log.Debugf("container stopped %s", c.ID)
905 905
 			}()
906 906
 		}
... ...
@@ -980,7 +980,7 @@ func (daemon *Daemon) Pause(c *Container) error {
980 980
 	if err := daemon.execDriver.Pause(c.command); err != nil {
981 981
 		return err
982 982
 	}
983
-	c.State.SetPaused()
983
+	c.SetPaused()
984 984
 	return nil
985 985
 }
986 986
 
... ...
@@ -988,7 +988,7 @@ func (daemon *Daemon) Unpause(c *Container) error {
988 988
 	if err := daemon.execDriver.Unpause(c.command); err != nil {
989 989
 		return err
990 990
 	}
991
-	c.State.SetUnpaused()
991
+	c.SetUnpaused()
992 992
 	return nil
993 993
 }
994 994
 
... ...
@@ -50,7 +50,7 @@ func (daemon *Daemon) ContainerRm(job *engine.Job) engine.Status {
50 50
 	}
51 51
 
52 52
 	if container != nil {
53
-		if container.State.IsRunning() {
53
+		if container.IsRunning() {
54 54
 			if forceRemove {
55 55
 				if err := container.Kill(); err != nil {
56 56
 					return job.Errorf("Could not kill running container, cannot remove - %v", err)
... ...
@@ -138,7 +138,7 @@ func (daemon *Daemon) canDeleteImage(imgID string, force, untagged bool) error {
138 138
 
139 139
 		if err := parent.WalkHistory(func(p *image.Image) error {
140 140
 			if imgID == p.ID {
141
-				if container.State.IsRunning() {
141
+				if container.IsRunning() {
142 142
 					if force {
143 143
 						return fmt.Errorf("Conflict, cannot force delete %s because the running container %s is using it%s, stop it and retry", utils.TruncateID(imgID), utils.TruncateID(container.ID), message)
144 144
 					}
... ...
@@ -70,7 +70,7 @@ func (daemon *Daemon) Containers(job *engine.Job) engine.Status {
70 70
 	writeCont := func(container *Container) error {
71 71
 		container.Lock()
72 72
 		defer container.Unlock()
73
-		if !container.State.Running && !all && n <= 0 && since == "" && before == "" {
73
+		if !container.Running && !all && n <= 0 && since == "" && before == "" {
74 74
 			return nil
75 75
 		}
76 76
 		if before != "" && !foundBefore {
... ...
@@ -87,10 +87,10 @@ func (daemon *Daemon) Containers(job *engine.Job) engine.Status {
87 87
 				return errLast
88 88
 			}
89 89
 		}
90
-		if len(filt_exited) > 0 && !container.State.Running {
90
+		if len(filt_exited) > 0 && !container.Running {
91 91
 			should_skip := true
92 92
 			for _, code := range filt_exited {
93
-				if code == container.State.GetExitCode() {
93
+				if code == container.GetExitCode() {
94 94
 					should_skip = false
95 95
 					break
96 96
 				}
... ...
@@ -111,7 +111,7 @@ func (daemon *Daemon) ContainerLogs(job *engine.Job) engine.Status {
111 111
 			}
112 112
 		}
113 113
 	}
114
-	if follow && container.State.IsRunning() {
114
+	if follow && container.IsRunning() {
115 115
 		errors := make(chan error, 2)
116 116
 		if stdout {
117 117
 			stdoutPipe := container.StdoutLogPipe()
... ...
@@ -110,7 +110,7 @@ func (m *containerMonitor) Start() error {
110 110
 	defer func() {
111 111
 		if afterRun {
112 112
 			m.container.Lock()
113
-			m.container.State.setStopped(exitStatus)
113
+			m.container.setStopped(exitStatus)
114 114
 			defer m.container.Unlock()
115 115
 		}
116 116
 		m.Close()
... ...
@@ -152,7 +152,7 @@ func (m *containerMonitor) Start() error {
152 152
 		m.resetMonitor(err == nil && exitStatus == 0)
153 153
 
154 154
 		if m.shouldRestart(exitStatus) {
155
-			m.container.State.SetRestarting(exitStatus)
155
+			m.container.SetRestarting(exitStatus)
156 156
 			m.container.LogEvent("die")
157 157
 			m.resetContainer(true)
158 158
 
... ...
@@ -243,7 +243,7 @@ func (m *containerMonitor) callback(processConfig *execdriver.ProcessConfig, pid
243 243
 		}
244 244
 	}
245 245
 
246
-	m.container.State.setRunning(pid)
246
+	m.container.setRunning(pid)
247 247
 
248 248
 	// signal that the process has started
249 249
 	// close channel only if not closed
... ...
@@ -22,7 +22,7 @@ func (daemon *Daemon) ContainerStart(job *engine.Job) engine.Status {
22 22
 		return job.Errorf("No such container: %s", name)
23 23
 	}
24 24
 
25
-	if container.State.IsRunning() {
25
+	if container.IsRunning() {
26 26
 		return job.Errorf("Container already started")
27 27
 	}
28 28
 
... ...
@@ -16,7 +16,7 @@ func (daemon *Daemon) ContainerStop(job *engine.Job) engine.Status {
16 16
 		t = job.GetenvInt("t")
17 17
 	}
18 18
 	if container := daemon.Get(name); container != nil {
19
-		if !container.State.IsRunning() {
19
+		if !container.IsRunning() {
20 20
 			return job.Errorf("Container already stopped")
21 21
 		}
22 22
 		if err := container.Stop(int(t)); err != nil {
... ...
@@ -22,7 +22,7 @@ func (daemon *Daemon) ContainerTop(job *engine.Job) engine.Status {
22 22
 	}
23 23
 
24 24
 	if container := daemon.Get(name); container != nil {
25
-		if !container.State.IsRunning() {
25
+		if !container.IsRunning() {
26 26
 			return job.Errorf("Container %s is not running", name)
27 27
 		}
28 28
 		pids, err := daemon.ExecutionDriver().GetPidsForContainer(container.ID)
... ...
@@ -12,7 +12,7 @@ func (daemon *Daemon) ContainerWait(job *engine.Job) engine.Status {
12 12
 	}
13 13
 	name := job.Args[0]
14 14
 	if container := daemon.Get(name); container != nil {
15
-		status, _ := container.State.WaitStop(-1 * time.Second)
15
+		status, _ := container.WaitStop(-1 * time.Second)
16 16
 		job.Printf("%d\n", status)
17 17
 		return engine.StatusOK
18 18
 	}
... ...
@@ -57,7 +57,7 @@ func waitContainerStart(t *testing.T, timeout time.Duration) *daemon.Container {
57 57
 	setTimeout(t, "Waiting for the container to be started timed out", timeout, func() {
58 58
 		for {
59 59
 			l := globalDaemon.List()
60
-			if len(l) == 1 && l[0].State.IsRunning() {
60
+			if len(l) == 1 && l[0].IsRunning() {
61 61
 				container = l[0]
62 62
 				break
63 63
 			}
... ...
@@ -150,8 +150,8 @@ func TestRunDisconnect(t *testing.T) {
150 150
 	// cause /bin/cat to exit.
151 151
 	setTimeout(t, "Waiting for /bin/cat to exit timed out", 2*time.Second, func() {
152 152
 		container := globalDaemon.List()[0]
153
-		container.State.WaitStop(-1 * time.Second)
154
-		if container.State.IsRunning() {
153
+		container.WaitStop(-1 * time.Second)
154
+		if container.IsRunning() {
155 155
 			t.Fatalf("/bin/cat is still running after closing stdin")
156 156
 		}
157 157
 	})
... ...
@@ -202,8 +202,8 @@ func TestRunDisconnectTty(t *testing.T) {
202 202
 	// In tty mode, we expect the process to stay alive even after client's stdin closes.
203 203
 
204 204
 	// Give some time to monitor to do his thing
205
-	container.State.WaitStop(500 * time.Millisecond)
206
-	if !container.State.IsRunning() {
205
+	container.WaitStop(500 * time.Millisecond)
206
+	if !container.IsRunning() {
207 207
 		t.Fatalf("/bin/cat should  still be running after closing stdin (tty mode)")
208 208
 	}
209 209
 }
... ...
@@ -247,7 +247,7 @@ func TestRunDetach(t *testing.T) {
247 247
 	closeWrap(stdin, stdinPipe, stdout, stdoutPipe)
248 248
 
249 249
 	time.Sleep(500 * time.Millisecond)
250
-	if !container.State.IsRunning() {
250
+	if !container.IsRunning() {
251 251
 		t.Fatal("The detached container should be still running")
252 252
 	}
253 253
 
... ...
@@ -328,7 +328,7 @@ func TestAttachDetach(t *testing.T) {
328 328
 	closeWrap(stdin, stdinPipe, stdout, stdoutPipe)
329 329
 
330 330
 	time.Sleep(500 * time.Millisecond)
331
-	if !container.State.IsRunning() {
331
+	if !container.IsRunning() {
332 332
 		t.Fatal("The detached container should be still running")
333 333
 	}
334 334
 
... ...
@@ -393,7 +393,7 @@ func TestAttachDetachTruncatedID(t *testing.T) {
393 393
 	closeWrap(stdin, stdinPipe, stdout, stdoutPipe)
394 394
 
395 395
 	time.Sleep(500 * time.Millisecond)
396
-	if !container.State.IsRunning() {
396
+	if !container.IsRunning() {
397 397
 		t.Fatal("The detached container should be still running")
398 398
 	}
399 399
 
... ...
@@ -426,7 +426,7 @@ func TestAttachDisconnect(t *testing.T) {
426 426
 	setTimeout(t, "Waiting for the container to be started timed out", 10*time.Second, func() {
427 427
 		for {
428 428
 			l := globalDaemon.List()
429
-			if len(l) == 1 && l[0].State.IsRunning() {
429
+			if len(l) == 1 && l[0].IsRunning() {
430 430
 				break
431 431
 			}
432 432
 			time.Sleep(10 * time.Millisecond)
... ...
@@ -461,15 +461,15 @@ func TestAttachDisconnect(t *testing.T) {
461 461
 
462 462
 	// We closed stdin, expect /bin/cat to still be running
463 463
 	// Wait a little bit to make sure container.monitor() did his thing
464
-	_, err := container.State.WaitStop(500 * time.Millisecond)
465
-	if err == nil || !container.State.IsRunning() {
464
+	_, err := container.WaitStop(500 * time.Millisecond)
465
+	if err == nil || !container.IsRunning() {
466 466
 		t.Fatalf("/bin/cat is not running after closing stdin")
467 467
 	}
468 468
 
469 469
 	// Try to avoid the timeout in destroy. Best effort, don't check error
470 470
 	cStdin, _ := container.StdinPipe()
471 471
 	cStdin.Close()
472
-	container.State.WaitStop(-1 * time.Second)
472
+	container.WaitStop(-1 * time.Second)
473 473
 }
474 474
 
475 475
 // Expected behaviour: container gets deleted automatically after exit
... ...
@@ -42,7 +42,7 @@ func TestRestartStdin(t *testing.T) {
42 42
 	if err := stdin.Close(); err != nil {
43 43
 		t.Fatal(err)
44 44
 	}
45
-	container.State.WaitStop(-1 * time.Second)
45
+	container.WaitStop(-1 * time.Second)
46 46
 	output, err := ioutil.ReadAll(stdout)
47 47
 	if err != nil {
48 48
 		t.Fatal(err)
... ...
@@ -72,7 +72,7 @@ func TestRestartStdin(t *testing.T) {
72 72
 	if err := stdin.Close(); err != nil {
73 73
 		t.Fatal(err)
74 74
 	}
75
-	container.State.WaitStop(-1 * time.Second)
75
+	container.WaitStop(-1 * time.Second)
76 76
 	output, err = ioutil.ReadAll(stdout)
77 77
 	if err != nil {
78 78
 		t.Fatal(err)
... ...
@@ -120,7 +120,7 @@ func TestStdin(t *testing.T) {
120 120
 	if err := stdin.Close(); err != nil {
121 121
 		t.Fatal(err)
122 122
 	}
123
-	container.State.WaitStop(-1 * time.Second)
123
+	container.WaitStop(-1 * time.Second)
124 124
 	output, err := ioutil.ReadAll(stdout)
125 125
 	if err != nil {
126 126
 		t.Fatal(err)
... ...
@@ -165,7 +165,7 @@ func TestTty(t *testing.T) {
165 165
 	if err := stdin.Close(); err != nil {
166 166
 		t.Fatal(err)
167 167
 	}
168
-	container.State.WaitStop(-1 * time.Second)
168
+	container.WaitStop(-1 * time.Second)
169 169
 	output, err := ioutil.ReadAll(stdout)
170 170
 	if err != nil {
171 171
 		t.Fatal(err)
... ...
@@ -227,7 +227,7 @@ func BenchmarkRunParallel(b *testing.B) {
227 227
 				complete <- err
228 228
 				return
229 229
 			}
230
-			if _, err := container.State.WaitStop(15 * time.Second); err != nil {
230
+			if _, err := container.WaitStop(15 * time.Second); err != nil {
231 231
 				complete <- err
232 232
 				return
233 233
 			}
... ...
@@ -492,13 +492,13 @@ func startEchoServerContainer(t *testing.T, proto string) (*daemon.Daemon, *daem
492 492
 	}
493 493
 
494 494
 	setTimeout(t, "Waiting for the container to be started timed out", 2*time.Second, func() {
495
-		for !container.State.IsRunning() {
495
+		for !container.IsRunning() {
496 496
 			time.Sleep(10 * time.Millisecond)
497 497
 		}
498 498
 	})
499 499
 
500 500
 	// Even if the state is running, lets give some time to lxc to spawn the process
501
-	container.State.WaitStop(500 * time.Millisecond)
501
+	container.WaitStop(500 * time.Millisecond)
502 502
 
503 503
 	strPort = container.NetworkSettings.Ports[p][0].HostPort
504 504
 	return daemon, container, strPort
... ...
@@ -606,17 +606,17 @@ func TestRestore(t *testing.T) {
606 606
 		t.Fatal(err)
607 607
 	}
608 608
 
609
-	if !container2.State.IsRunning() {
609
+	if !container2.IsRunning() {
610 610
 		t.Fatalf("Container %v should appear as running but isn't", container2.ID)
611 611
 	}
612 612
 
613 613
 	// Simulate a crash/manual quit of dockerd: process dies, states stays 'Running'
614 614
 	cStdin, _ := container2.StdinPipe()
615 615
 	cStdin.Close()
616
-	if _, err := container2.State.WaitStop(2 * time.Second); err != nil {
616
+	if _, err := container2.WaitStop(2 * time.Second); err != nil {
617 617
 		t.Fatal(err)
618 618
 	}
619
-	container2.State.SetRunning(42)
619
+	container2.SetRunning(42)
620 620
 	container2.ToDisk()
621 621
 
622 622
 	if len(daemon1.List()) != 2 {
... ...
@@ -626,7 +626,7 @@ func TestRestore(t *testing.T) {
626 626
 		t.Fatal(err)
627 627
 	}
628 628
 
629
-	if !container2.State.IsRunning() {
629
+	if !container2.IsRunning() {
630 630
 		t.Fatalf("Container %v should appear as running but isn't", container2.ID)
631 631
 	}
632 632
 
... ...
@@ -639,7 +639,7 @@ func TestRestore(t *testing.T) {
639 639
 	}
640 640
 	runningCount := 0
641 641
 	for _, c := range daemon2.List() {
642
-		if c.State.IsRunning() {
642
+		if c.IsRunning() {
643 643
 			t.Errorf("Running container found: %v (%v)", c.ID, c.Path)
644 644
 			runningCount++
645 645
 		}
... ...
@@ -654,7 +654,7 @@ func TestRestore(t *testing.T) {
654 654
 	if err := container3.Run(); err != nil {
655 655
 		t.Fatal(err)
656 656
 	}
657
-	container2.State.SetStopped(0)
657
+	container2.SetStopped(0)
658 658
 }
659 659
 
660 660
 func TestDefaultContainerName(t *testing.T) {
... ...
@@ -96,12 +96,12 @@ func containerAttach(eng *engine.Engine, id string, t log.Fataler) (io.WriteClos
96 96
 }
97 97
 
98 98
 func containerWait(eng *engine.Engine, id string, t log.Fataler) int {
99
-	ex, _ := getContainer(eng, id, t).State.WaitStop(-1 * time.Second)
99
+	ex, _ := getContainer(eng, id, t).WaitStop(-1 * time.Second)
100 100
 	return ex
101 101
 }
102 102
 
103 103
 func containerWaitTimeout(eng *engine.Engine, id string, t log.Fataler) error {
104
-	_, err := getContainer(eng, id, t).State.WaitStop(500 * time.Millisecond)
104
+	_, err := getContainer(eng, id, t).WaitStop(500 * time.Millisecond)
105 105
 	return err
106 106
 }
107 107
 
... ...
@@ -112,7 +112,7 @@ func containerKill(eng *engine.Engine, id string, t log.Fataler) {
112 112
 }
113 113
 
114 114
 func containerRunning(eng *engine.Engine, id string, t log.Fataler) bool {
115
-	return getContainer(eng, id, t).State.IsRunning()
115
+	return getContainer(eng, id, t).IsRunning()
116 116
 }
117 117
 
118 118
 func containerAssertExists(eng *engine.Engine, id string, t log.Fataler) {
... ...
@@ -303,7 +303,7 @@ func runContainer(eng *engine.Engine, r *daemon.Daemon, args []string, t *testin
303 303
 		return "", err
304 304
 	}
305 305
 
306
-	container.State.WaitStop(-1 * time.Second)
306
+	container.WaitStop(-1 * time.Second)
307 307
 	data, err := ioutil.ReadAll(stdout)
308 308
 	if err != nil {
309 309
 		return "", err